formsintegerintsetterjsf-1.2

JSF does not call setter method of selected Item


Here is a JSF 1.1 form

<h:form>
    <h1>STEP 1 - Choose your channels</h1>        
        <h:selectManyCheckbox value="#{globalTVRegistration.selectedChannels}" layout="pageDirection">
            <f:selectItems value="#{globalTVRegistration.availableChannels}" />                
        </h:selectManyCheckbox>
    <h:commandButton value="Select Channels" action="packages" />
</h:form>

and its corresponding backing bean

public class GlobalTVRegistration {

    private int[] selectedChannels;

    public int[] getSelectedChannels() {
        return selectedChannels;
    }

    public void setSelectedChannels(int[] selectedItems) {
        this.selectedChannels = selectedItems;
    }

}    

When I select one or more checkboxes and click the command button, the same page is refreshed again. The form submission does not call setSelectedChannels(int[] selectedItems).

Can you identify the problem?


Solution

  • In case others also face the same problem, on line

    private int[] selectedChannels;
    

    replace int data type with Integer.