f:validateDoubleRange

The f:validateDoubleRange Facelet tag exposes the functionality of a DoubleRangeValidator inside Facelet views.

General Usage

The minimum and maximum attributes can be used to specify the range limits for a floating point value.



                   

Codi font

<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', 1.25, 2.50)}</label>
		<h:inputText id="double" value="#{validationModelBean.doubleNumber}"
			label="#{i18n['f-validatedoublerange-label']}">
			<f:validateDoubleRange minimum="1.25" maximum="2.50" />
		</h:inputText>
		<br />
		<h:message for="double" />
		<hr />
		<h:commandButton value="#{i18n['submit']}">
			<f:ajax	execute="@form" render="@form" />
		</h:commandButton>
		<h:outputText value="#{validationModelBean.doubleNumber}" />
	</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 5.0.0 + Liferay Faces Portal 5.0.0 + Showcase Common 3.1.1 + Liferay Faces Util 3.4.1 + Mojarra 2.2.20