<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<%@ page contentType="text/html;charset=utf-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<!-- RichFaces tag library declaration -->
<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
<%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
<html>
<f:view>
<head>
<title>JSF in Action - Validator examples</title>
</head>
<body>
<h1>
Validator examples
</h1>
<h:form>
<table border="1" cellspacing="0" cellpadding="5">
<tr>
<td>
<b>Validator(s)</b>
</td>
<td>
<b>Comments</b>
</td>
<td>
<b>Input</b>
</td>
<td>
<b>Errors</b>
</td>
</tr>
<tr>
<td>
Validation method
</td>
<td>
validator=testForm.validateEmail
</td>
<td>
<h:inputText id="methodInput"
validator="#{testForm.validateEmail}" />
</td>
<td>
<h:message for="methodInput" style="color: red" />
</td>
</tr>
<tr>
<td>
None (component property)
</td>
<td>
required="true"
</td>
<td>
<h:selectOneMenu id="RequiredInput" required="true">
<f:selectItem itemValue="" itemLabel="" />
<f:selectItem itemValue="1" itemLabel="dogs" />
<f:selectItem itemValue="2" itemLabel="birds" />
<f:selectItem itemValue="3" itemLabel="hamsters" />
</h:selectOneMenu>
</td>
<td>
<h:message for="RequiredInput" style="color: red" />
</td>
</tr>
<tr>
<td>
Length
</td>
<td>
minimum="2"
<br>
maxmimum="10"
</td>
<td>
<h:inputText id="LengthInput">
<f:validateLength minimum="2" maximum="10" />
</h:inputText>
</td>
<td>
<h:message for="LengthInput" style="color: red" />
</td>
</tr>
<tr>
<td>
LongRange
</td>
<td>
minimum="5"
<br>
maxmimum="999999"
</td>
<td>
<h:inputText id="LongRangeInput">
<f:validateLongRange minimum="5" maximum="999999" />
</h:inputText>
</td>
<td>
<h:message for="LongRangeInput" style="color: red" />
</td>
</tr>
<tr>
<td>
DoubleRange
</td>
<td>
minimum="5.1"
<br>
maxmimum="6.76"
</td>
<td>
<h:selectOneRadio id="DoubleRangeInput">
<f:selectItem itemValue="5.0" itemLabel="5.0" />
<f:selectItem itemValue="6.1" itemLabel="6.1" />
<f:selectItem itemValue="6.8" itemLabel="6.8" />
<f:validateDoubleRange minimum="5.1" maximum="6.76" />
</h:selectOneRadio>
</td>
<td>
<h:message for="DoubleRangeInput" style="color: red" />
</td>
</tr>
<tr>
<td>
Length, LongRange
</td>
<td>
required="true"
<br>
Length minimum="2"
<br>
Length maxmimum="3"
<br>
LongRange minimum="10"
<br>
LongRange maxmimum="999"
</td>
<td>
<h:inputText id="MultiInput" required="true">
<f:validateLength minimum="2" maximum="3" />
<f:validateLongRange minimum="10" maximum="999" />
</h:inputText>
</td>
<td>
<h:message for="MultiInput" style="color: red" />
</td>
</tr>
</table>
<p>
<h:commandButton value="Go!" />
</h:form>
</body>
</f:view>
</html>