JSF - Enviar datos de un boton a txt 1 y txt 2

 
Vista:

Enviar datos de un boton a txt 1 y txt 2

Publicado por Alejandro (1 intervención) el 28/09/2015 06:14:49
Hola gente!!,

Tengo el siguiente problema, espero me puedan colaborar: tengo dos cajas de texto (txt1 y txt2), tengo un boton, tengo un checkbox o BooleanCheckbox, cuando presiono el boton me envia a la caja de texto 1 (txt1), pero si activo el checkbox para enviar la caja de texto 2 (txt2) este no me envia, no he encontrado la forma de validar esto, es posible que me puedan ayudar, gracias, esto es lo q' llevo.

Lo estoy trabajando con JSF y JSF Managed Bean con RequestScoped

esto es en el index.xhtml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<h:form>
.
.
.
<h:outputLabel value="caja 1: " />
            <h:inputText id="cext" value="#{indexBean.ctext}" />
                <br></br>
            <h:outputLabel value="Caja 2: " />
            <h:inputText id="ctext2" value="#{indexBean.ctext2}" />
            <h:selectManyCheckbox>
                <f:selectItem id="cj2" itemValue="enviar datos caja 2" itemDisabled="false"  />
            </h:selectManyCheckbox>
 
     <h:commandButton  value="1" action="#{indexBean.bN1()}"  />
.
.
.
</h:form>

Esto es en la clase bean
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
@ManagedBean
@RequestScoped
public class P {
 
    private String ctext;
    private String ctext2;
    private int b1;
 
 public String getCtext() {
        return ctext;
    }
 
    public void setCtext(String ctext) {
        this.ctext = ctext;
    }
 
    public String getCtext2() {
        return ctext2;
    }
 
    public void setCtext2(String ctext2) {
        this.ctext2 = ctext2;
    }
 
public int getB1() {
        return b1;
    }
 
    public void setB1(int b1) {
        this.b1 = b1;
 
public void bN1(){
       if(b1==b1){
            int bt1=1;
            ctext+=String.valueOf(bt1);
        }else if(cj2==true){
            int bt1=1;
            ctext2+=String.valueOf(bt1);
        }else{
            System.out.println("nada");
        }
    }
 
}

Graicas por su ayuda,

Slds,
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder