tags:

views:

434

answers:

1

I have a JSF page where I am need to pre-check one of the checkboxes on the page, when it is first loaded. How would I go about doing this? I know I can bind the control to the backing bean but at what point would I set the values to populate the selectmany item?

My page contains:-

<h:selectManyCheckbox
 disabledClass="selectManyCheckbox_Disabled"  
    styleClass="selectManyCheckbox" id="checkbox2"
 required="true" value="#{pc_Proposaldeclaration.selectedDistWho}" >

 <f:selectItem itemLabel="item1" itemValue="Name1" />
    <f:selectItem itemLabel="item2" itemValue="Name2" />

</h:selectManyCheckbox>

Any help in setting the "item1" to checked on page load appreciated!

A: 

When you initialize (either in the constructor or your framework's Initialize method) is the place you would preselect the values. For example, JSF1.2 has the @PostConstruct annotation which will execute after a bean has been created and has access to the context.

Drew