JSF Showcase
h:selectManyListbox
HtmlSelectManyListbox is a UISelectMany component that renders aselect
element and enables the user to select multiple values.
Instant Ajax Usage
The component supports instant Ajax by simply adding f:ajax as a child tag.Source Code
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:f="http://xmlns.jcp.org/jsf/core" xmlns:ui="http://xmlns.jcp.org/jsf/facelets"> <h:form> <h:outputLabel value="#{i18n['favorite-liferay-benefit']}" /> <h:selectManyListbox id="selectManyListbox" value="#{selectManyModelBean.favoriteIds}"> <f:selectItem itemLabel="Compatible" itemValue="1" /> <f:selectItem itemLabel="Enterprise Ready" itemValue="2" /> <f:selectItem itemLabel="Powerful Integration" itemValue="3" /> <f:selectItem itemLabel="Lightweight" itemValue="4" /> <f:selectItem itemLabel="Open Source" itemValue="5" /> <f:ajax render="@form" /> </h:selectManyListbox> <h:panelGroup id="modelValue"> <ui:repeat value="#{selectManyModelBean.favoriteIds}" var="favoriteId"> <h:outputText value="#{favoriteId}" /><br /> </ui:repeat> </h:panelGroup> </h:form> </ui:composition>
@ManagedBean @RequestScoped public class SelectManyModelBean { private List<Long> favoriteIds; private List<Long> benefitIds = Arrays.asList(2L, 4L); private List<Date> dates; private String phase; @ManagedProperty(name = "liferayBenefitService", value = "#{liferayBenefitService}") private LiferayBenefitService liferayBenefitService; public List<Long> getBenefitIds() { return benefitIds; } public List<Date> getDates() { return dates; } public List<Long> getFavoriteIds() { return favoriteIds; } public List<LiferayBenefit> getLiferayBenefits() { return liferayBenefitService.getLiferayBenefits(); } public String getPhase() { return phase; } public void setBenefitIds(List<Long> benefitIds) { this.benefitIds = benefitIds; } public void setDates(List<Date> dates) { this.dates = dates; } public void setFavoriteIds(List<Long> favoriteIds) { this.favoriteIds = favoriteIds; } public void setLiferayBenefitService(LiferayBenefitService liferayBenefitService) { this.liferayBenefitService = liferayBenefitService; } public void setPhase(String phase) { this.phase = phase; } }
Liferay Faces Bridge Implementation 5.0.0 + Showcase Common 3.1.1 + Liferay Faces Util 3.4.1 + Mojarra 2.2.20