jsf 2 - selectCheckboxMenu primefaces return empty List -
i'm trying selected values selectcheckboxmenu
using primefaces 5.3 , jsf 2, selection list empty.
this html part:
<p:selectcheckboxmenu id="cours" value="#{etudiantcontroller.checkedcours}" converter="#{coursconverter}" label="liste cours available" multiple="true" panelstyle="width:250px"> <f:selectitems value="#{etudiantcontroller.coursetudiant}" var="coursetd" itemlabel="#{coursetd.libellecours}" itemvalue="#{coursetd.idcours}" /> </p:selectcheckboxmenu>
bean part:
private list<cours> checkedcours; for(cours courstoadd : checkedcours){ system.out.println("enter ... !!!"); coursservice.addcours(courstoadd); }
converter :
public class coursconverter implements converter { public object getasobject(facescontext context, uicomponent component, string value) { if (value != null && !value.isempty()) { return component.getattributes().get(value); } return null; } public string getasstring(facescontext context, uicomponent component, object value) { if (value == null) { return ""; } if (value instanceof cours) { cours cours = (cours) value; string name = cours.getlibellecours(); return name; } else { throw new converterexception(new facesmessage(value + " est un cours non valide")); } } }
the problem here never enter in block.
any help? thank you.
try setting id converter , calling using id
@facesconverter("coursconverter") public class coursconverter implements converter { ... }
--
<p:selectcheckboxmenu id="cours" value="#{etudiantcontroller.checkedcours}" converter="coursconverter" label="liste cours available" multiple="true" panelstyle="width:250px"> <f:selectitems value="#{etudiantcontroller.coursetudiant}" var="coursetd" itemlabel="#{coursetd.libellecours}" itemvalue="#{coursetd.idcours}" />
Comments
Post a Comment