[dataTable] La table ne se met pas à jour après suppression d'une ligne
Bonjour,
J'ai une dataTable dans laquelle je peux supprimer des lignes via un commandLink et un dialogue de confirmation.
Le problème est qu'après suppression, la liste ne se met pas à jour et je dois rafraichir la page pour voir disparaitre la ligne supprimée.
Ce qui est bizarre, c'est que ça marchait à un moment donné et d'un coup par hasard, j'ai remarqué que ça ne fonctionnait plus. J'ai beau regarder les modifs faites, je ne vois pas ce qui pourrait engendrer ça.
Voici la page 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 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 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
|
<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:fn="http://java.sun.com/jsp/jstl/functions"
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']}"
sortMode="multiple"
rowKey="#{identite.id}" paginator="true" paginatorPosition="bottom"
rows="10" style="margin-bottom:10px"
paginatorTemplate=" {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="10,30,50">
<f:facet name="header">
<p:outputPanel>
<div align="left">
<p:link outcome="saisirIdentite" value="# #{msg['AjouterUneIdentite']}" />
</div>
</p:outputPanel>
</f:facet>
<p:column style="width:16px">
<p:rowToggler />
</p:column>
<p:column headerText="#{msg['ID']}" style="width:3%" rendered="#{gestionIdentitesForm.userSuperAdmin}" >
<h:outputText value="#{identite.id}" />
</p:column>
<p:column filterBy="#{identite.typeIdentiteCi}" filterOptions="#{gestionIdentitesForm.typesIdentiteOptions}" filterMatchMode="exact" headerText="#{msg['Type']}" style="width:10%">
<h:outputText value = "#{identite.typeIdentiteCi.nom}" />
</p:column>
<p:column sortBy="#{identite.nom}" headerText="#{msg['Nom']}" style="width:10%" filterBy="#{identite.nom}" filterMatchMode="contains" >
<h:outputText value="#{identite.nom}" />
</p:column>
<!-- filterMatchMode="startsWith" -->
<p:column sortBy="#{identite.prenom}" headerText="#{msg['Prenom']}" style="width:10%" filterBy="#{identite.prenom}" filterMatchMode="contains" >
<h:outputText value="#{identite.prenom}" />
</p:column>
<p:column sortBy="#{identite.raisonSociale}" headerText="#{msg['RaisonSociale']}" style="width:15%" filterBy="#{identite.raisonSociale}" filterMatchMode="contains" >
<h:outputText value="#{identite.raisonSociale}" />
</p:column>
<p:column headerText="#{msg['Rue']}" style="width:15%">
<h:outputText value="#{identite.adressePrincipale.rueNumero}" />
</p:column>
<!-- Affiche soit la localité pré-enregistrée, la localité libre ou un message -->
<p:column headerText="#{msg['Localite']}" style="width:10%">
<h:outputText value="#{identite.adressePrincipale.localite}" rendered="#{not empty identite.adressePrincipale.localite.nom}"/>
<h:outputText value="#{identite.adressePrincipale.codePostalLibre} #{identite.adressePrincipale.localiteLibre}" rendered="#{not empty identite.adressePrincipale.localiteLibre}" />
</p:column>
<p:column headerText="#{msg['NoTelProf']}" style="width:8%">
<h:outputText value="#{identite.adressePrincipale.noTelProf}" />
</p:column>
<p:column headerText="#{msg['NoTelMobile']}" style="width:8%">
<h:outputText value="#{identite.adressePrincipale.noTelMobile}" />
</p:column>
<p:column headerText="#{msg['Actions']}" style="width:7%">
<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:rowExpansion>
<h:panelGrid id="displayDetail" columns="4" cellpadding="10" style="margin-bottom:10px; margin-top:10px; width:1000px;"
columnClasses="detailTitre, detailValeur, detailTitre, detailValeur">
<h:outputText value="#{msg['CasePostale']}" />
<h:outputText value="#{identite.adressePrincipale.casePostale}" />
<h:outputText value="#{msg['Email']}" />
<a href="mailto:#{identite.adressePrincipale.email}" >#{identite.adressePrincipale.email}</a>
<h:outputText value="#{msg['Canton']}" />
<h:outputText value="#{identite.adressePrincipale.localite.canton}" />
<h:outputText value="#{msg['NoTelPrive']}" />
<h:outputText value="#{identite.adressePrincipale.noTelPrive}"/>
<h:outputText value="#{msg['Pays']}" />
<h:outputText value="#{identite.adressePrincipale.pays}" />
<h:outputText value="#{msg['NoFax']}" />
<h:outputText value="#{identite.adressePrincipale.noFax}"/>
</h:panelGrid>
</p:rowExpansion>
<f:facet name="footer">
#{fn:length(gestionIdentitesForm.listIdentites)} #{msg['IdentitesEnregistrees']}
</f:facet>
</p:dataTable>
<p:messages id="messages" autoUpdate="true" globalOnly="true" />
</h:form>
</ui:define>
</ui:composition> |
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
|
@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;
private List<TypeIdentiteCi> listTypeIdentite;
private SelectItem[] typesIdentiteOptions;
@EJB
private IdentiteService m_identiteService;
/**
* Default Constructor
*/
public GestionIdentitesForm() {
typesIdentiteOptions = createFilterOptions();
}
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<TypeIdentiteCi> getListTypeIdentite() {
if (listTypeIdentite == null) {
listTypeIdentite = new ArrayList<>();
listTypeIdentite.add(TypeIdentiteCi.PHYSIQUE);
listTypeIdentite.add(TypeIdentiteCi.MORALE);
}
return listTypeIdentite;
}
public List<Identite> getListIdentites() {
if (listIdentites == null) {
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);
ajouterMessage("LIdentiteAEteSupprimeeAvecSucces", FacesMessage.SEVERITY_INFO);
} catch (Throwable e) {
ajouterMessage("ImpossibleDeSupprimerLIdentite", FacesMessage.SEVERITY_INFO);
ajouterMessage(e.getCause().getCause().getMessage(), FacesMessage.SEVERITY_ERROR);
}
}
public Identite getSelectedIdentite() {
return selectedIdentite;
}
public void setSelectedIdentite(Identite selectedIdentite) {
this.selectedIdentite = selectedIdentite;
}
private void ajouterMessage(String message, Severity severity) {
FacesContext facesContext = FacesContext.getCurrentInstance();
Flash flash = facesContext.getExternalContext().getFlash();
flash.setKeepMessages(true);
flash.setRedirect(true);
facesContext.addMessage(null,
Messages.getMessage(message, severity, null));
}
public SelectItem[] getTypesIdentiteOptions() {
return typesIdentiteOptions;
}
private SelectItem[] createFilterOptions() {
SelectItem[] options = new SelectItem[3];
options[0] = new SelectItem("", Messages.getString("Tous", null));
options[1] = new SelectItem(TypeIdentiteCi.PHYSIQUE.getNom(), TypeIdentiteCi.PHYSIQUE.getNom());
options[2] = new SelectItem(TypeIdentiteCi.MORALE.getNom(), TypeIdentiteCi.MORALE.getNom());
return options;
}
} |
Qqun a-t-il une idée ?
Merci d'avance pour votre aide