Search code examples
javajsficefaces

Icefaces selectMultipleCheckbox checked


I have a selectManyCheckbox component. categories is an array list of selectItems that I insert inside of it so it creates multiple checkboxes with proper names. I also have another array list that decides if the checkbox is going to be checked initially, called categoriy_checked. Does anyone know where I have to place it to make it work? Cause I couldn't find a selected or checked property or anything similar.

<ice:selectManyCheckbox id="master_categories" layout = "pageDirection">
     <f:selectItems id="category_master" value="#{ticket.categories}" />
</ice:selectManyCheckbox>

Solution

  • Just bind the input component's value to a bean property the usual way (I assume that you already have it; how would you ever collect the submitted values?):

    <ice:selectManyCheckbox value="#{ticket.selectedCategories}">
    

    It should map to a List or array of items of the same type as the item value of #{ticket.categories}. You can just fill the selected item(s) in bean's (post)constructor.

    private List<Category> selectedCategories;
    
    @PostConstruct
    public void init() {
        selectedCategories = createAndFillItSomehow();
    }