2 pièce(s) jointe(s)
Ajout d'un bouton « + » à droite d'un champ texte qui fait apparaître 3 champs dynamiquement
Bonjour,
Je souhaite ajouter un bouton « + » à droite d'un champ texte comme dans l'image ci dessous (le résultat souhaité):
Mais j'ai un problème au niveau du bouton (+) de deuxième champs qui n'affiche pas le troisième champs..est ce que vous avez une idée
Pièce jointe 151407
merci pour votre aide
voici le code que j'ai développé
la page xhtml :
Code:
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
| <?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<h:head>
</h:head>
<h:body>
<h:form >
<h:panelGroup id="display0" >
<div></div>
<p:inputText id="champs1" value="#{monBean.champs1}" />
<p:commandButton value="+" rendered="#{monBean.boutton1}" action="#{monBean.afficherLigne2()}" update="display0" />
<div></div>
<h:panelGroup rendered="#{nomDomaines.afficherChamps2}" >
<p:inputText id="champs2" value="#{monBean.champs2}" />
<h:panelGroup>
<p:commandButton value="+" action="#{monBean.afficherLigne3()}" rendered="#{monBean.boutton2}" update="display0" />
<div></div>
<h:panelGroup rendered="#{nomDomaines.afficherChamps3}" >
<p:inputText id="champs3" value="#{monBean .champs3}" />
<h:panelGroup>
<div></div>
<div></div>
</h:panelGroup>
</h:form>
</h:body>
</html> |
le code java :
Code:
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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
| import java.io.Serializable;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
@ManagedBean
public class MonBean implements Serializable {
private String champs1;
private String champs2;
private String champs3;
private boolean boutton1;
private boolean boutton2;
private boolean boutton3;
private boolean afficherChamps2;
private boolean afficherChamps3;
@PostConstruct
public void init() {
boutton1 = true;
}
public void afficherLigne2() {
boutton1 = false;
boutton2 = true;
boutton3 = false;
afficherChamps2 = true;
afficherChamps3 = false;
}
public void afficherLigne3() {
boutton1 = false;
boutton2 = false;
boutton3 = true;
afficherChamps2 = true;
afficherChamps3 = true;
}
public boolean getBoutton1() {
return boutton1;
}
public void setBoutton1(boolean boutton1) {
this.boutton1 = boutton1;
}
public boolean getBoutton2() {
return boutton2;
}
public void setBoutton2(boolean boutton2) {
this.boutton2 = boutton2;
}
public boolean isBoutton3() {
return boutton3;
}
public void setBoutton3(boolean boutton3) {
this.boutton3 = boutton3;
}
public boolean isAfficherChamps2() {
return afficherChamps2;
}
public void setAfficherChamps2(boolean afficherChamps2) {
this.afficherChamps2 = afficherChamps2;
}
public boolean isAfficherChamps3() {
return afficherChamps3;
}
public void setAfficherChamps3(boolean afficherChamps3) {
this.afficherChamps3 = afficherChamps3;
}
public String getChamps1() {
return champs1;
}
public void setChamps1(String champs1) {
this.champs1 = champs1;
}
public String getChamps2() {
return champs2;
}
public void setChamps2(String champs2) {
this.champs2 = champs2;
}
public String getChamps3() {
return champs3;
}
public void setChamps3(String champs3) {
this.champs3 = champs3;
}
} |