Problème de récupération de données dans un p:selectManyCheckBox
Bonjour,
Je m'explique, j'ai une application qui référence des profils et des droits. Il existe au total 31 droits.
Un profil possède un certain nombre de droits.
Je suis en train de créer une page qui permettra de rajouter ou supprimer des droits sur un profil en les cochant ou décochant.
J'ai actuellement un profil qui possèdent 5 droits et lorsque j'arrive sur la page de modification du profil, je retrouve bien mes 31 droits existant mais les droit qui sont déjà acquis pour ce profil ne sont pas sélectionnés dans mon selectManyCheckBox...
Voici le code du formulaire :
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
| <?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 > Profils
<br/>
<b style="font-size: 30px">Modifier/Supprimer un profil</b>
<br/><br/>
<h:form id="formModifierProfil">
<p:selectManyCheckbox id="droitsGeneraux" value="#{modifierProfilBean.profilSelectionnee._tab_droits}" layout="grid" columns="1" converter="#{genericConverter}">
<f:selectItems value="#{modifierProfilBean.listeDroitsGeneraux}" var="droit" itemLabel="#{droit._libelleIhm}" itemValue="#{droit}"/>
</p:selectManyCheckbox>
</h:form>
</ui:define>
</ui:composition>
</html> |
Voici le code du Bean associé :
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
|
@ManagedBean
@ViewScoped
public class ModifierProfilBean extends AbstractPageBean {
// ************************* Variables ****************************************
@EJB
private ProfilService_Itf serviceProfil;
@EJB
private DroitService_Itf serviceDroit;
private Collection<DroitDto> listeDroitsGeneraux;
private ProfilDto profilSelectionnee;
public ModifierProfilBean() {
profilSelectionnee = (ProfilDto) JsfUtils.getFromSession("profilSelectionnee");
}
/**
* Méthode qui initialise la page avant son affichage.
*/
@PostConstruct
private void initModificationProfil() {
serviceProfil = PerseeUserBusiness.getProfilService();
serviceDroit = PerseeUserBusiness.getDroitService();
listeDroitsGeneraux = serviceDroit.findAll();
for (DroitDto unDroit : profilSelectionnee.get_tab_droits()) {
System.out.println("ce profil a " + profilSelectionnee.get_tab_droits().size() + " droits / " + listeDroitsGeneraux.size() + " --> " + unDroit.get_libelleIhm());
}
}
+ getters / setters
} |
Le for à la fin de mon postConstruct renvoi bien les 5 droits qui devraient être coché dans mon selectManyCheckBox mais ils ne sont pas cochés dans ma page xhtml.