Voilà c'est fait. mais ça ne change rien, c'est ce que j'avais fais au début...
Bon je me sauve pour l'instant, je reviendrai demain à la charge !
Version imprimable
Voilà c'est fait. mais ça ne change rien, c'est ce que j'avais fais au début...
Bon je me sauve pour l'instant, je reviendrai demain à la charge !
Hello, je suis enfin parvenu à mes fins !!!
Il fallait travailler en java
Je devrais pouvoir un peu optimiser mon code, mais pour l'instant ça marche.
Voici le code de ma page principale :
- Vous verrez que j'ai fixé les rendered des h:panelsgroups à true ou false pour l'inistialisation.
- Remarquez également la présence de bindings sur les différents panels
Voici le code Java, il nécessite quelques optimisations, mais c'est un détail.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 <?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" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:ez="http://java.sun.com/jsf/composite/ezcomp/entree"> <ui:composition template="/template/base.xhtml"> <ui:define id="titre" name="titre">Entrez dans une nouvelle Ere</ui:define> <ui:define id="haut" name="haut">monhaut</ui:define> <ui:define id ="gauche" name="gauche"> <h:panelGroup id="GrouppeDeBouton"> <h:commandButton id="boutonPageConnexion" value="Entrée" actionListener="#{environnement.actionBoutonPageConnexion}"> <f:ajax render="panelContenuGlobal" /> </h:commandButton> <h:commandButton id="boutonPageInscription" value="Inscrivez vous" actionListener="#{environnement.actionBoutonPageInscription}"> <f:ajax render="panelContenuGlobal" /> </h:commandButton> <h:commandButton id="boutonPageRegle" value="Les règles" actionListener="#{environnement.actionBoutonPageRegle}"> <f:ajax render="panelContenuGlobal" /> </h:commandButton> </h:panelGroup> </ui:define> <ui:define id="defineContenu" name="contenu"> <h:panelGroup id="panelContenuGlobal"> <h:panelGroup id="panelConnexion" rendered="true" binding="#{environnement.panelConnexion}"> <ui:include id="includeContenu" src="sousPageEntree/connexion.xhtml"/> </h:panelGroup> <h:panelGroup id="panelInscription" rendered="false" binding="#{environnement.panelInscription}"> <ui:include id="includeContenu" src="sousPageEntree/inscription.xhtml"/> </h:panelGroup> <h:panelGroup id="panelRegle" rendered="false" binding="#{environnement.panelRegle}"> <ui:include id="includeContenu" src="sousPageEntree/regle.xhtml"/> </h:panelGroup> </h:panelGroup> </ui:define> </ui:composition> </html>
- après les différents événements on modifie l'état des h:panelgroup ici avec un HtmlPanelGroup.setRendered(true ou false)
- Ensuite on sauve leur état par un HtmlPanelGroup.saveState.
Merci à sniper qui m'a aidé.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 package objet.session; import java.io.Serializable; import javax.faces.bean.ManagedBean; import javax.faces.bean.SessionScoped; import javax.faces.component.html.HtmlPanelGroup; import javax.faces.context.FacesContext; import javax.faces.event.ActionEvent; @ManagedBean(name="environnement") @SessionScoped public class Environnement implements Serializable { private String sousPageEnCours; public HtmlPanelGroup panelConnexion; public HtmlPanelGroup panelInscription; public HtmlPanelGroup panelRegle; public HtmlPanelGroup getPanelConnexion() { return panelConnexion; } public void setPanelConnexion(HtmlPanelGroup panelConnexion) { this.panelConnexion = panelConnexion; } public HtmlPanelGroup getPanelInscription() { return panelInscription; } public void setPanelInscription(HtmlPanelGroup panelInscription) { this.panelInscription = panelInscription; } public HtmlPanelGroup getPanelRegle() { return panelRegle; } public void setPanelRegle(HtmlPanelGroup panelRegle) { this.panelRegle = panelRegle; } public String getSousPageEnCours() { return sousPageEnCours; } public void setSousPageEnCours(String sousPageEnCours) { this.sousPageEnCours = sousPageEnCours; if(sousPageEnCours.equals("sousPageEntree/connexion.xhtml")){ panelConnexion.setRendered(true); panelInscription.setRendered(false); panelRegle.setRendered(false); } else if(sousPageEnCours.equals("sousPageEntree/inscription.xhtml")){ panelConnexion.setRendered(false); panelInscription.setRendered(true); panelRegle.setRendered(false); } else if(sousPageEnCours.equals("sousPageEntree/regle.xhtml")){ panelConnexion.setRendered(false); panelInscription.setRendered(false); panelRegle.setRendered(true); } FacesContext contexte=FacesContext.getCurrentInstance(); panelConnexion.saveState(contexte); panelInscription.saveState(contexte); panelRegle.saveState(contexte); } public Environnement(){ } public void actionBoutonPageConnexion(ActionEvent e){ this.setSousPageEnCours("sousPageEntree/connexion.xhtml"); } public void actionBoutonPageInscription(ActionEvent e){ this.setSousPageEnCours("sousPageEntree/inscription.xhtml"); } public void actionBoutonPageRegle(ActionEvent e){ this.setSousPageEnCours("sousPageEntree/regle.xhtml"); } }