jsf 2 - Bind value directly to JSF selectItem without p:selectManyCheckbox value -
so it's this.
mymb:
class="lang-java prettyprint-override">@named("mymb") @sessionscoped public class mysupercoolmb implements serializable { //tons of attributes private list<listmodelone> lmo = new arraylist(); //tons of methods }
outter model:
class="lang-java prettyprint-override">public class listmodelone { private coolobject object; private list<readwrite> permissions; //init() //setters-getters }
inner model, model needs bind straight selectitems on screen
class="lang-java prettyprint-override">public class readwrite { private string accessitem; private boolean read = false; private boolean write = false; //somewhere in code alter true/false depending //what need , alter in title in xhtml. //setters-getters }
and xhtml:
class="lang-xhtml prettyprint-override"><h3>cool title</h3> <p:accordionpanel value="#{mymb.lmo}" var="modelone"> <p:tab title="#{modelone.coolobject.objectname}"> <h3>cool inner title</h3> <ui:repeat value="#{modelone.permissions}" var="readwrite"> <h:panelgrid> <h:outputtext value="#{readwrite.accessitem}"/> <!-- selectmanycheckbox has no value attribute because don't need/have list/collection bind --> <p:selectmanycheckbox> <f:selectitem itemlabel="read" itemvalue="#{readwrite.read}" title="this set #{readwrite.read}"/> <f:selectitem itemlabel="write" itemvalue="#{readwrite.write}" title="this set #{readwrite.write}"/> </p:selectmanycheckbox> </h:panelgrid> </ui:repeat> </p:tab> </p:accordionpanel>
everything works fine checkboxes (selectitem), can bound straight attribute of class , ignote value of p:selectmanycheckboxes? works fine on java, i've debugged , values right, print ok on "tittle" attribute in f:selectitem (some true, , false)
ps: couldn't understand difference between itemlabel, label, itemvalue, value
does aspect against using 2 <p:selectbooleancheckbox>
?
otherwise i'd propose code this:
<h:panelgrid> <h:outputtext value="#{readwrite.accessitem}"/> <p:selectbooleancheckbox value="read" itemlabel="#{readwrite.read}" /> <p:selectbooleancheckbox value="write" itemlabel="#{readwrite.write}" /> </h:panelgrid>
look @ this: http://www.primefaces.org/showcase/ui/input/booleancheckbox.xhtml
itemvalue , itemlabel used if want dynamically generate selectoptions (like checkboxes or options in dropdown-menu etc). example:
// java-class... @named( public enum selectoption(){ max, oliver, john; } // in bean... private list<selectoption> fornames; // setter & getter // in xhtml... <p:selectmanycheckbox value="#{bean.fornames}"> <f:selectitems value="#{bean.fornames.values()}" var="forname" itemvalue="#{forname}" itemlabel="#{forname.tostring()}" /> </p:selectmanycheckbox>
explanation: list in bean selected items. f:selectitems
-tag takes possible options enumeration (you can hand on collection), , iterates on every "forname"-object in collection. in case, itemvalue represents have list of object save in, , label, phone call tostring-method.
i hope explained understandable.
jsf jsf-2 primefaces nested
No comments:
Post a Comment