c:set

c:set becomes useful for setting a value to a JavaBean or an scoped variable.

General Usage

Set value for specifying which value you want to set, and then there are two possible options:
  • Store the value in a scoped variable. Set var and scope attributes for that purpose.
  • Set the value to a JavaBean property. In this case, just use target for the bean name, and property for the bean property name to be set.
Enabled

Rendered bean value is:true

Codi font

<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
	xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:ui="http://xmlns.jcp.org/jsf/facelets">

	<c:set target="#{jSTLBackingBean}" property="rendered" value="#{true}"/>

	<c:if test="#{jSTLBackingBean.rendered}">
			Enabled<br/><br/>
	</c:if>

	<h:outputText value="#{i18n['rendered-bean-value-is']}:#{jSTLBackingBean.rendered}"/>

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

	private boolean rendered;

	public boolean isRendered() {
		return rendered;
	}

	public void setRendered(boolean rendered) {
		this.rendered = rendered;
	}

	public void toggleRendered(ActionEvent event) {
		this.rendered = !rendered;
	}

}
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