As with any other input component, just bind its attribute valueusing the managed bean. It can match with Listor an array of the same type of values that you used in f:selectItem(s). If the value type is not one of the standard EL types ( String, Numberor Boolean), then you must also supply Converter.
Here is an example with a type value String:
<h:selectManyListbox value="#{bean.selectedItems}">
<f:selectItems value="#{bean.availableItems}" />
</h:selectManyListbox>
<h:commandButton value="Submit" action="#{bean.submit}" />
with
public class Bean {
private Map<String, String> availableItems;
private List<String> selectedItems;
@PostConstruct
public void init() {
availableItems = new LinkedHashMap<String, String>();
availableItems.put("Foo label", "foo");
availableItems.put("Bar label", "bar");
availableItems.put("Baz label", "baz");
}
public void submit() {
System.out.println(selectedItems);
}
}
See also:
source
share