JSF Showcase

f:validateLongRange

The f:validateLongRange Facelet tag exposes the functionality of a LongRangeValidator inside Facelet views.

General Usage

The minimum and maximum attributes can be used to specify the range limits for an integer value.


Source Code

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

	<h:form>
		<label class="control-label">#{i18n.replace('please-enter-a-value-between-x-and-x', 5, 8)}</label>
		<h:inputText id="long" value="#{validationModelBean.longNumber}"
			label="#{i18n['f-validatelongrange-label']}">
			<f:validateDoubleRange minimum="5" maximum="8" />
		</h:inputText>
		<br />
		<h:message for="long" />
		<hr />
		<h:commandButton value="#{i18n['submit']}">
			<f:ajax	execute="@form" render="@form" />
		</h:commandButton>
		<h:outputText value="#{validationModelBean.longNumber}" />
	</h:form>

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

	@Pattern(regexp = ".+[@].+[.].+")
	private String email;
	private Double doubleNumber;
	private Long longNumber;
	private String otherText;

	public Double getDoubleNumber() {
		return doubleNumber;
	}

	public String getEmail() {
		return email;
	}

	public Long getLongNumber() {
		return longNumber;
	}

	public String getOtherText() {
		return otherText;
	}

	public void setDoubleNumber(Double doubleNumber) {
		this.doubleNumber = doubleNumber;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public void setLongNumber(Long longNumber) {
		this.longNumber = longNumber;
	}

	public void setOtherText(String otherText) {
		this.otherText = otherText;
	}
}
Liferay Faces Bridge Implementation 4.0.0 + Showcase Common 3.0.0 + Liferay Faces Util 3.0.1-SNAPSHOT + Mojarra 2.2.13