[dataTable] Tri et filtre ne fonctionnent pas
Bonjour,
J'ai une dataTable dans laquelle j'affiche des identités.
J'aimerais non seulement pouvoir trier mais aussi filtre^r certaines colonnes.
J'ai mis quelque chose en place en me référant au site primefaces.org mais aussi bien le tri que le filtre ne fonctionne pas.
Qqun a-t-il une idée ?
Voici la page :
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 108 109 110
|
<ui:composition template="../../secured/modele/template.xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<ui:define name="contenu">
<h:form id="gestionIdentitesForm">
<!-- <p:growl id="messages" life="2000" /> -->
<!-- Dialogue de confirmation de suppression d'une identité -->
<p:dialog header="#{msg['ConfirmerLaSuppression']}" widgetVar="confDeleteDlg" resizable="false" id="confDelDlg"
showEffect="fade" hideEffect="fade" >
<p:outputLabel value="#{msg['EtesVousSurDeVouloirSupprimerCetteIdentite']}" />
<div align="center">
<h:panelGrid id="display" columns="2" cellpadding="10">
<p:commandButton id="deleteButton" action="#{gestionIdentitesForm.supprimerIdentite}" oncomplete="PF('confDeleteDlg').hide()"
update=":gestionIdentitesForm:identites, messages" value="#{msg['Oui']}" />
<p:commandButton id="cancelButton" onclick="PF('confDeleteDlg').hide()" value="#{msg['Non']}"/>
</h:panelGrid>
</div>
</p:dialog>
<!-- Tableau d'affichage des identités -->
<h2>
<h:outputText value="#{msg['GestionDesIdentites']}" />
</h2>
<p:dataTable id="identites"
value="#{gestionIdentitesForm.listIdentites}"
var="identite" widgetVar="identiteTable" filteredValue="#{gestionIdentitesForm.listIdentitesFiltered}"
emptyMessage="#{msg['AucuneIdentiteAAfficher']}"
editable="false" editmode="row"
sortMode="multiple" rowKey="#{identite.id}" paginator="true" paginatorPosition="bottom"
rows="10" style="margin-bottom:10px"
paginatorTemplate=" {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="10,20,50">
<f:facet name="header">
<p:outputPanel>
<div align="left">
<p:link outcome="saisirIdentite" value="# #{msg['AjouterUneIdentite']}" />
</div>
</p:outputPanel>
</f:facet>
<p:column headerText="#{msg['ID']}" style="width:4%" rendered="#{gestionIdentitesForm.userSuperAdmin}">
#{identite.id}
</p:column>
<p:column headerText="#{msg['Type']}" style="width:3%">
#{identite.typePersonneCi.abrege}
</p:column>
<p:column filterBy="nom" filterMatchMode="contains" sortBy="#{nom}" headerText="#{msg['Nom']}" style="width:15%">
#{identite.nom}
</p:column>
<p:column sortBy="#{prenom}" headerText="#{msg['Prenom']}" style="width:15%">
#{identite.prenom}
</p:column>
<p:column headerText="#{msg['RaisonSociale']}" sortBy="#{raisonSociale}" style="width:15%">
#{identite.raisonSociale}
</p:column>
<p:column headerText="#{msg['Rue']}" style="width:10%">
#{identite.adressePrincipale.rueNumero}
</p:column>
<p:column headerText="#{msg['Localite']}" style="width:10%">
<c:choose>
<c:when test="#{not empty identite.adressePrincipale.localite}">#{identite.adressePrincipale.localite}</c:when>
<c:otherwise>#{identite.adressePrincipale.codePostalLibre} #{identite.adressePrincipale.localiteLibre}</c:otherwise>
</c:choose>
</p:column>
<p:column headerText="#{msg['NoTelProf']}" style="width:10%">
#{identite.adressePrincipale.noTelProf}
</p:column>
<p:column headerText="#{msg['NoTelMobile']}" style="width:10%">
#{identite.adressePrincipale.noTelMobile}
</p:column>
<p:column headerText="#{msg['NoTelPrive']}" style="width:10%">
#{identite.adressePrincipale.noTelPrive}
</p:column>
<p:column headerText="#{msg['Email']}" style="width:10%">
#{identite.adressePrincipale.email}
</p:column>
<p:column headerText="#{msg['Actions']}" style="width:13%">
<p:link value="# #{msg['Modifier']}" outcome="saisirIdentite" >
<f:param name="idIdentite" value="#{identite.id}" />
</p:link>
/
<p:commandLink value="# #{msg['Supprimer']}" onclick="PF('confDeleteDlg').show()" >
<f:setPropertyActionListener target="#{gestionIdentitesForm.selectedIdentite}" value="#{identite}"/>
</p:commandLink>
</p:column>
</p:dataTable>
<p:messages id="messages" autoUpdate="true" globalOnly="true" />
</h:form>
</ui:define>
</ui:composition> |
Et le bean :
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
|
@ManagedBean(name = "gestionIdentitesForm")
@ViewScoped
public class GestionIdentitesForm implements Serializable {
private static final long serialVersionUID = 1L;
private List<Identite> listIdentites;
private List<Identite> listIdentitesFiltered;
private Identite selectedIdentite;
@EJB
private IdentiteService m_identiteService;
/**
* Default Constructor
*/
public GestionIdentitesForm() {
}
public boolean isUserSuperAdmin() {
FacesContext context = FacesContext.getCurrentInstance();
ExternalContext externalContext = context.getExternalContext();
HttpSession session = ((HttpServletRequest) externalContext.getRequest()).getSession();
Employe currentUser = (Employe) session.getAttribute("user");
return currentUser != null && currentUser.isSuperAdmin();
}
public List<Identite> getListIdentites() {
listIdentites = m_identiteService.getIdentiteList();
return listIdentites;
}
public void setListIdentites(List<Identite> listIdentites) {
this.listIdentites = listIdentites;
}
public List<Identite> getListIdentitesFiltered() {
return listIdentitesFiltered;
}
public void setListIdentitesFiltered(List<Identite> listIdentitesFiltered) {
this.listIdentitesFiltered = listIdentitesFiltered;
}
public void supprimerIdentite() {
try {
m_identiteService.deleteIdentite(selectedIdentite);
FacesContext.getCurrentInstance().addMessage(
null,
Messages.getMessage("LIdentiteAEteSupprimeeAvecSucces",
FacesMessage.SEVERITY_INFO, null));
} catch (Throwable e) {
FacesContext.getCurrentInstance().addMessage(
null,
new FacesMessage(Messages.getMessage("ImpossibleDeSupprimerLIdentite",
FacesMessage.SEVERITY_INFO, null).getDetail() + " : "));
FacesContext.getCurrentInstance().addMessage(
null,
new FacesMessage(e.getCause().getCause().getMessage()));
}
}
public Identite getSelectedIdentite() {
return selectedIdentite;
}
public void setSelectedIdentite(Identite selectedIdentite) {
this.selectedIdentite = selectedIdentite;
}
} |
Merci d'avance pour votre aide