jsf - Preselect items in h:selectManyCheckbox -



jsf - Preselect items in h:selectManyCheckbox -

how preselect elements in h:selectmanycheckbox component? i've searched through properties of f:selectitem tag not yet have found how pre-select item (i.e. ticked when site called).

the value attribute of h:selectmanycheckbox can take array of string managed bean. can straight set default values array when managed bean initialized.

for illustration , in view :

<h:selectmanycheckbox value="#{mbean.choice}"> <f:selectitem itemvalue="a" itemlabel="choice a" /> <f:selectitem itemvalue="b" itemlabel="choice b" /> <f:selectitem itemvalue="c" itemlabel="choice c"/> <f:selectitem itemvalue="d" itemlabel="choice d" /> </h:selectmanycheckbox>

then in mbean :

public class mbean{ //preselect "choice a" , "choice c" private string[] choice= {"a","c"}; //getter , setter of selection }

jsf jsf-2

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -