Usecase : How to use af:selectManyChoice component.
Implementation
Below is the sample screenshot how this component looks like. User can allowed to select more than one item.
Below is the snippet in Page fragment, ValueChangeListener method binding is optional. this is one way of getting selected values. <f:selectItems> value can bind to any data source. In this example I have pointed to one Java class that returns list of <SelectItem>'s
This is how we can populate List of SelectItem values, I have configured this class in faces-config.xml, so that every page fragment can access these values.
Below screenshot shows how to get the selected value from <af:selectManyChoice> component by changing value on it. valueChangeEvent.getNewValue() returns selected values in form of java.util.ArrayList<Object>
Note : If you bind <f:selectItems> to List<SelectItems> , You will always get the selected item(s) key value instead of index value.
Implementation
Below is the sample screenshot how this component looks like. User can allowed to select more than one item.
Below is the snippet in Page fragment, ValueChangeListener method binding is optional. this is one way of getting selected values. <f:selectItems> value can bind to any data source. In this example I have pointed to one Java class that returns list of <SelectItem>'s
This is how we can populate List of SelectItem values, I have configured this class in faces-config.xml, so that every page fragment can access these values.
Below screenshot shows how to get the selected value from <af:selectManyChoice> component by changing value on it. valueChangeEvent.getNewValue() returns selected values in form of java.util.ArrayList<Object>
Note : If you bind <f:selectItems> to List<SelectItems> , You will always get the selected item(s) key value instead of index value.