JSF Showcase
f:validateLength
The f:validateLength Facelet tag exposes the functionality of a LengthValidator inside Facelet views.General Usage
The minimum and maximum attributes can be used to specify the length limits for an input 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-between-x-and-x-characters', 5, 9)}</label> <h:inputText id="length" value="#{inputTextModelBean.text}" label="#{i18n['f-validatelength-label']}"> <f:validateLength maximum="9" minimum="5" /> </h:inputText> <br /> <h:message for="length" /> <hr /> <h:commandButton value="#{i18n['submit']}"> <f:ajax execute="@form" render="@form" /> </h:commandButton> <h:outputText value="#{inputTextModelBean.text}" /> </h:form> </ui:composition>
@ManagedBean @RequestScoped public class InputTextModelBean { private Date date = new GregorianCalendar().getTime(); private String text; public Date getDate() { return date; } public String getText() { return text; } public void setDate(Date date) { this.date = date; } public void setText(String text) { this.text = text; } }
Liferay Faces Bridge Implementation 5.0.0 + Showcase Common 3.1.1 + Liferay Faces Util 3.4.1 + Mojarra 2.2.20