JSF Showcase
h:selectOneListbox
HtmlSelectOneListbox is a UISelectOne component that renders aselect
element (multi-item list) and enables the user to select one value.
Instant Ajax Usage
The value attribute can be bound to a model bean property via EL.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:selectOneListbox id="selectOneListbox" value="#{selectOneModelBean.favoriteId}"> <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:selectOneListbox> <h:outputText id="modelValue" value="#{selectOneModelBean.favoriteId}" /> </h:form> </ui:composition>
@ManagedBean @RequestScoped public class SelectOneModelBean { private Long favoriteId; private Long benefitId = 3L; private Date date; private String phase; @ManagedProperty(name = "liferayBenefitService", value = "#{liferayBenefitService}") private LiferayBenefitService liferayBenefitService; public Long getBenefitId() { return benefitId; } public Date getDate() { return date; } public Long getFavoriteId() { return favoriteId; } public List<LiferayBenefit> getLiferayBenefits() { return liferayBenefitService.getLiferayBenefits(); } public String getPhase() { return phase; } public void setBenefitId(Long benefitId) { this.benefitId = benefitId; } public void setDate(Date date) { this.date = date; } public void setFavoriteId(Long favoriteId) { this.favoriteId = favoriteId; } 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