Bonjour,
Tout est dans le titre, je n'arrive pas à faire fonctionner mon fiterBy et mon SortBy dans un Datatable.
Trouvez ci-dessous mon code ainsi que le Bean associé.
Code page xhtml : Sélectionner tout - Visualiser dans une fenêtre à part
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 <?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:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui" xmlns:pe="http://primefaces.org/ui/extensions"> <ui:composition template="../../WEB-INF/templates/standard.xhtml"> <ui:define name="content"> <p:graphicImage library="images" name="home.png" width="1%"/> > Administration > Compte <br/> <b style="font-size: 30px">Modifier/Supprimer un compte</b> <br/><br/> <p:focus for="tabComptes"/> <p:dataTable emptyMessage="Aucun enregistrement" id="tabComptes" widgetVar="wvCompte" filteredValue="#{modifierCompteBean.lstComptesFiltre}" paginatorPosition="bottom" currentPageReportTemplate="{currentPage}/{totalPages} pages * {startRecord}-{endRecord}/{totalRecords} enr." paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}" selectionMode="single" paginatorAlwaysVisible="true" var="compte" selection="#{modifierCompteBean.compteSelectionnee}" value="#{modifierCompteBean.listeComptes}" rowKey="#{compte.id}" paginator="true" sortBy="#{compte._nom}" rows="10" > <f:facet name="header"> <h:outputText value="Selectionner un compte"/> </f:facet> <p:column filterBy="#{compte._nom}" sortBy="#{compte._nom}" headerText="Nom" filterMatchMode="contains" > <h:outputText value="#{compte._nom}"/> </p:column> <p:column filterBy="#{compte._prenom}" sortBy="#{compte._prenom}" headerText="Prenom" filterMatchMode="contains" > <h:outputText value="#{compte._prenom}"/> </p:column> <p:column filterBy="#{compte.identifiant}" sortBy="#{compte.identifiant}" headerText="Identifiant" filterMatchMode="contains" > <h:outputText value="#{compte.identifiant}"/> </p:column> <p:column sortBy="#{compte._compteBloque}" headerText="Compte Bloqué" > <h:graphicImage library="images" id="imageBloque" name="/#{compte._compteBloque}.png" width="20px" height="20px" /> </p:column> <p:column sortBy="#{compte._nbTentative}" headerText="Nombre tentatives" > <h:outputText value="#{compte._nbTentative}"/> </p:column> </p:dataTable> <br/> <center> <p:commandButton id="BoutonModifier" value="Modifier/Supprimer" /> </center> </ui:define> </ui:composition> </html>
Code bean : Sélectionner tout - Visualiser dans une fenêtre à part
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
108 package fr.gouv.persee.compte; import java.text.Normalizer; import java.util.ArrayList; import java.util.Collection; import java.util.Date; import java.util.List; import javax.annotation.PostConstruct; import javax.ejb.EJB; import javax.ejb.Stateless; import javax.faces.application.FacesMessage; import javax.faces.bean.ManagedBean; import javax.faces.bean.ViewScoped; import javax.swing.text.AbstractDocument.LeafElement; import fr.gouv.persee.business.PerseeUserBusiness; import fr.gouv.persee.business.api.persee.administration.CompteDto; import fr.gouv.persee.business.api.persee.administration.CompteService_Itf; import fr.gouv.persee.business.api.persee.administration.ProfilDto; import fr.gouv.persee.business.api.persee.administration.ProfilService_Itf; import fr.gouv.persee.business.api.persee.programmation.EscadronDto; import fr.gouv.persee.business.api.persee.programmation.EscadronService_Itf; import fr.gouv.persee.common.AbstractPageBean; import fr.gouv.persee.common.JsfUtils; import fr.spi4j.exception.Spi4jValidationException; @ManagedBean @ViewScoped public class ModifierCompteBean extends AbstractPageBean { // ************************* Constantes *************************************** private String CHAMP_NON_VALIDE = "/resources/images/Icon-warning2"; private String CHAMP_VALIDE = "/resources/images/ui-icons_persee_greenTick"; // ************************* Variables **************************************** @EJB private CompteService_Itf serviceCompte; @EJB private EscadronService_Itf serviceEscadron; @EJB private ProfilService_Itf serviceProfil; private String nom; private String prenom; private EscadronDto unite; private String identifiant; private Collection<EscadronDto> listeEscadrons; private boolean identifiantOk; private CompteDto compteSelectionnee; private Collection<ProfilDto> listeProfils; private List<ProfilDto> profilsSelectionnes; private String champsObligatoirePrenom; private String champsObligatoireNom; private String champsObligatoireUnite; private String champsObligatoireProfils; private boolean afficherFormModif; private Collection<CompteDto> listeComptes; private List<CompteDto> lstComptesFiltre; // ************************* Constructeurs *********************************** public ModifierCompteBean() { } @PostConstruct private void initCreationCompte() { serviceEscadron = PerseeUserBusiness.getEscadronService(); serviceCompte = PerseeUserBusiness.getCompteService(); serviceProfil = PerseeUserBusiness.getProfilService(); listeEscadrons = serviceEscadron.findAll(); identifiantOk = false; compteSelectionnee = new CompteDto(); listeProfils = serviceProfil.findAll(); listeComptes = serviceCompte.findAll(); champsObligatoireNom = CHAMP_NON_VALIDE; champsObligatoirePrenom = CHAMP_NON_VALIDE; champsObligatoireProfils = CHAMP_NON_VALIDE; champsObligatoireUnite = CHAMP_NON_VALIDE; afficherFormModif = false; } public boolean afficherFormulaire(){ if ((compteSelectionnee.get_nom() != null) || (compteSelectionnee.get_nom() == "")){ afficherFormModif = true; } else { afficherFormModif = false; } return afficherFormModif; } + tous les getters / setters !!! }
Partager