I use the datatable with checkbox selection feature, but when I click on footer button after selecting some rows, thoses rows don't be affected to my object selectedCommandes[], and the proof is that I added a row in the method that show me the lenght of selectedCommandes[] but it return 0, I don't know why, I think all my codes are good here is the datatable :
<p:dataTable id="cars" var="car" value="#{commandesUserController.mediumCommandesModel}" selection="#{commandesUserController.selectedCommandes}" tableStyle="width:auto">
<f:facet name="header">
Checkbox Based Selection
</f:facet>
<p:column selectionMode="multiple" style="width:18px" />
<p:column headerText="Model" style="width:100px">
<h:outputText value="#{car.id}" />
</p:column>
<p:column headerText="Year" style="width:100px">
<h:outputText value="#{car.dateEnvoi}" />
</p:column>
<p:column headerText="Manufacturer" style="width:100px">
<h:outputText value="#{car.dateLivraisonRecommande}" />
</p:column>
<p:column>
<p:commandLink ajax="false" value="Editer" action="updateUser_v1" >
<f:setPropertyActionListener value="#{car}" target="#{editUserController.u1}" />
</p:commandLink>
</p:column>
<p:column>
<p:commandLink value="Supprimer" oncomplete="confirmation.show()" >
<f:setPropertyActionListener value="#{car}" target="#{commandesUserController.selectedCommande}" />
</p:commandLink>
</p:column>
<p:column style="width:40px">
<p:commandButton id="selectButton" update=":myform:carDlg" oncomplete="carDialog.show()" icon="ui-icon-search" title="View">
<f:setPropertyActionListener value="#{car}" target="#{commandesUserController.selectedCommande}" />
</p:commandButton>
</p:column>
<f:facet name="footer">
<p:commandButton id="supprion" value="supprimer selection" oncomplete="confirmation2.show()" />
</f:facet>
</p:dataTable>
and here is the button where there is the problem :
<f:facet name="footer">
<p:commandButton id="supprion" value="supprimer selection" oncomplete="confirmation2.show()" />
</f:facet>
and here is the dialog that appears when I click in the button above :
<p:confirmDialog id="confirmDialog2" message="etes vous sur de vouloir supprimer ces commande avec tous les données et fichiers correspondants !"
header="confirmation de suppression" severity="alert" widgetVar="confirmation2">
<p:commandButton id="confirm2" value="oui" update="cars" oncomplete="confirmation2.hide()"
action="#{commandesUserController.deleteCommandes()}" />
<p:commandButton id="decline2" value="non" onclick="confirmation2.hide()" type="button" />
</p:confirmDialog>
and here is the method in the managedBean :
public String deleteCommandes(){
System.out.println("je suis dans delete l ensemble avec tous = "+selectedCommandes.length);
for(int j = 0;j<selectedCommandes.length;j++){
selectedCommandes[j].setListFichiers(uh.getFichiersById(this.selectedCommandes[j].getId()));
for(int i = 0; i<selectedCommandes[j].getListFichiers().size();i++){
//System.out.println("alors "+selectedCommande.getListFichiers().get(i).getId());
uh.deleteFichier(selectedCommandes[j].getListFichiers().get(i));
}
uh.deleteCommande(selectedCommandes[j]);
}
return "commandesUser";
}
this line : System.out.println("je suis dans delete l ensemble avec tous = "+selectedCommandes.length); always return 0
I already created the class that implement SelectableDataModel
I hope I explained the problem
do you have any idea thank you