<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@taglib uri="http://richfaces.org/rich" prefix="rich"%>
<%@taglib prefix="a4j" uri="http://richfaces.org/a4j"%>
<html>
<head>
<title>Hibernate validator test</title>
</head>
<body>
<h1>Using Hibernate validator annotations in the JSF beans</h1>
<f:view>
	<h:form id="form">
	<rich:panel>
	  <f:facet name="header">
		<h:outputText>Single input field with label and message. Validated by AJAX on every char.</h:outputText>
	  </f:facet>
				<h:outputLabel for="ltext" value="#{lengthBean.textDescription}" />
				<h:inputText id="ltext" value="#{lengthBean.text}">
					<rich:ajaxValidator event="onkeyup" />
				</h:inputText>
				<rich:message for="ltext" showDetail="true" showSummary="true" />
	</rich:panel>
		<h2>Input fields with label and message in the JSF dataTable. Each field validated by AJAX on "onblur" event</h2>
	    <rich:graphValidator value="#{data}" >
		<rich:dataTable value="#{data.beans}" var="bean" id="table">
				<f:facet name="header">
					<h:outputText value="Validate values in the data table. Total sum for an all integer values validated for a value less then 20" />
				</f:facet>

			<h:column>
				<f:facet name="header">
					<h:outputText value="text field" />
				</f:facet>
				<h:outputLabel for="text" value="#{bean.textDescription}" />
				<h:inputText id="text" value="#{bean.text}">
					<rich:ajaxValidator event="onblur" />
				</h:inputText>
				<rich:message for="text" showDetail="true" showSummary="true" />
			</h:column>
			<h:column>
				<f:facet name="header">
					<h:outputText value="integer field" />
				</f:facet>
				<h:outputLabel for="intValue" value="#{bean.intDescription}" />
				<h:inputText id="intValue" value="#{bean.intValue}">
					<rich:ajaxValidator event="onblur" />
				</h:inputText>
				<rich:message for="intValue" showDetail="true" showSummary="true" />
			</h:column>
			<f:facet name="footer">
				<h:panelGroup>
		<h:outputText>in addition to fields validation, total sum for an all integer values validated for a value less then 20.</h:outputText>
	<h:commandButton value="Submit all fields"></h:commandButton>
				</h:panelGroup>
			</f:facet>
		</rich:dataTable>
		</rich:graphValidator>
	</h:form>
	<rich:messages  />
</f:view>
</body>
</html>
