h:selectBooleanCheckbox

HtmlSelectBooleanCheckbox is a UISelectBoolean component that renders a checkbox.

Instant Ajax Usage

The component supports instant Ajax by simply adding f:ajax as a child tag.
I agree to the terms of the license agreement

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:selectBooleanCheckbox id="checkbox" value="#{selectBooleanCheckboxModelBean.agree}">
			<f:ajax render="@form" />
		</h:selectBooleanCheckbox>
		<h:outputText value="#{i18n['i-agree-to-the-terms-of-the-license-agreement']}" />
		<h:outputText id="modelValue" value="#{selectBooleanCheckboxModelBean.agree}" />
	</h:form>

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

	private Boolean agree;

	public Boolean getAgree() {
		return agree;
	}

	public void setAgree(Boolean agree) {
		this.agree = agree;
	}
}
@ManagedBean
@RequestScoped
public class SelectBooleanCheckboxBackingBean {

	private static final Logger logger = LoggerFactory.getLogger(SelectBooleanCheckboxBackingBean.class);

	@ManagedProperty(name = "selectBooleanCheckboxModelBean", value = "#{selectBooleanCheckboxModelBean}")
	private SelectBooleanCheckboxModelBean selectBooleanCheckboxModelBean;

	public void setSelectBooleanCheckboxModelBean(SelectBooleanCheckboxModelBean selectBooleanCheckboxModelBean) {
		this.selectBooleanCheckboxModelBean = selectBooleanCheckboxModelBean;
	}

	public void submit() {
		PhaseId phaseId = FacesContext.getCurrentInstance().getCurrentPhaseId();
		logger.info("submit: phaseId=[{0}] agree=[{1}]", phaseId.toString(), selectBooleanCheckboxModelBean.getAgree());
	}

	public void valueChangeListener(ValueChangeEvent valueChangeEvent) {

		FacesContext facesContext = FacesContext.getCurrentInstance();
		PhaseId phaseId = facesContext.getCurrentPhaseId();
		logger.debug("valueChangeListener: phaseId=[{0}]", phaseId.toString());

		String phaseName = phaseId.toString();
		FacesMessage facesMessage = new FacesMessage("The valueChangeListener method was called during the " +
				phaseName + " phase of the JSF lifecycle.");
		facesContext.addMessage(null, facesMessage);
	}
}
Liferay Faces Bridge Implementation 5.0.0 + Showcase Common 3.1.1 + Liferay Faces Util 3.4.1 + Mojarra 2.2.20