portal:nav

Nav is a UIData (iterator) component that renders a <ul>...</ul> (unordered) list. It is designed to be used in conjunction with portal:navItem child component tags.

Data Model Usage

Since it extends UIData, it can render list items dynamically when the portal:navItem content is set via EL to a model bean property (which is wrapped implicitly by JSF with a DataModel). The var attribute can be used to introduce a variable name into the EL when iterating over the model.

ソースコード

<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://xmlns.jcp.org/jsf/html"
	xmlns:portal="http://liferay.com/faces/portal"
	xmlns:ui="http://xmlns.jcp.org/jsf/facelets">

	<h:form>
		<portal:nav responsive="false" value="#{navModelBean.liferayBenefits}" var="liferayBenefit">
			<portal:navItem>
				<h:commandLink>
					<h:graphicImage name="icon-#{liferayBenefit.imageName}" library="images" />
					<h:outputText value="#{liferayBenefit.label}" />
				</h:commandLink>
			</portal:navItem>
		</portal:nav>
	</h:form>

</ui:composition>
@RequestScoped
@ManagedBean
public class NavModelBean {

	@ManagedProperty(name = "liferayBenefitService", value = "#{liferayBenefitService}")
	private LiferayBenefitService liferayBenefitService;

	public List<LiferayBenefit> getLiferayBenefits() {
		return liferayBenefitService.getLiferayBenefits();
	}

	public void setLiferayBenefitService(LiferayBenefitService liferayBenefitService) {
		this.liferayBenefitService = liferayBenefitService;
	}
}
Liferay Faces Bridge Implementation 5.0.0 + Liferay Faces Portal 5.0.0 + Showcase Common 3.1.1 + Liferay Faces Util 3.4.1 + Mojarra 2.2.20