Portal Showcase
f:validateRegex
The f:validateRegex Facelet tag exposes the functionality of a RegexValidator inside Facelet views.General Usage
The pattern attribute can be used to specify a regular expression validation pattern 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['please-enter-your-email']}</label> <h:inputText id="email" value="#{inputTextModelBean.text}" label="#{i18n['validate-email-label']}"> <f:validateRegex pattern=".+[@].+[.].+" /> </h:inputText> <br /> <h:message for="email" /> <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 + Liferay Faces Portal 5.0.0 + Showcase Common 3.1.1 + Liferay Faces Util 3.4.1 + Mojarra 2.2.20