Author: jjamrich
Date: 2012-01-12 20:08:50 -0500 (Thu, 12 Jan 2012)
New Revision: 23141
Added:
modules/tests/metamer/trunk/application/src/main/webapp/components/richValidator/csvOnJsr303.xhtml
Log:
RF-11846: add example to simulate rich:validator with many inputs
Added:
modules/tests/metamer/trunk/application/src/main/webapp/components/richValidator/csvOnJsr303.xhtml
===================================================================
---
modules/tests/metamer/trunk/application/src/main/webapp/components/richValidator/csvOnJsr303.xhtml
(rev 0)
+++
modules/tests/metamer/trunk/application/src/main/webapp/components/richValidator/csvOnJsr303.xhtml 2012-01-13
01:08:50 UTC (rev 23141)
@@ -0,0 +1,223 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
+
+ <!--
+JBoss, Home of Professional Open Source
+Copyright 2010-2011, Red Hat, Inc. and individual contributors
+by the @authors tag. See the copyright.txt in the distribution for a
+full listing of individual contributors.
+
+This is free software; you can redistribute it and/or modify it
+under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation; either version 2.1 of
+the License, or (at your option) any later version.
+
+This software is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this software; if not, write to the Free
+Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ -->
+
+ <ui:composition template="/templates/template.xhtml">
+
+ <ui:define name="view">
+ <f:metadata>
+ <f:viewParam name="templates"
value="#{templateBean.templates}">
+ <f:converter converterId="templatesListConverter" />
+ </f:viewParam>
+ </f:metadata>
+ </ui:define>
+
+ <ui:define name="head">
+ <style type="text/css">
+ .rf-msg-err {
+ display: block !important;
+ margin-bottom: 6px;
+ }
+ </style>
+ </ui:define>
+
+ <ui:define name="component">
+ <script type="text/javascript">
+ function setCorrectValues() {
+ var today = new Date();
+ var inPast = new Date(today.getTime() - 4 * 24 * 3600 * 1000);
+ var inFuture = new Date(today.getTime() + 4 * 24 * 3600 * 1000);
+
+ $('input[id$=assertTrue]')[0].checked = true;
+ $('input[id$=assertFalse]')[0].checked = false;
+ $('input[id$=decimalMinMax]').val('3');
+ $('input[id$=digits]').val('2.567');
+ $('input[id$=max]').val('9');
+ $('input[id$=min]').val('4');
+ $('input[id$=minMax]').val('4');
+ $('input[id$=notEmpty]').val('RichFaces 4');
+ $('input[id$=notNull]').val('RichFaces 4');
+ $('input[id$=custom]').val('RichFaces');
+ $('input[id$=pattern]').val('richFaces 4');
+ $('input[id$=past]').val(inPast.format("d mmm yyyy"));
+ $('input[id$=future]').val(inFuture.format("d mmm
yyyy"));
+ $('input[id$=stringSize]').val('JSF');
+ $('input[value=A]')[0].checked=true
+ $('input[value=B]')[0].checked=true
+ $('input[value=C]')[0].checked=false
+ $('input[value=D]')[0].checked=false
+ $('input[value=E]')[0].checked=false
+ $('input[value=F]')[0].checked=false
+ }
+
+ function setWrongValues() {
+ var today = new Date();
+ var inPast = new Date(today.getTime() - 4 * 24 * 3600 * 1000);
+ var inFuture = new Date(today.getTime() + 4 * 24 * 3600 * 1000);
+
+ $('input[id$=assertTrue]')[0].checked = false;
+ $('input[id$=assertFalse]')[0].checked = true;
+ $('input[id$=decimalMinMax]').val('10.668');
+ $('input[id$=digits]').val('15.627123');
+ $('input[id$=max]').val('122');
+ $('input[id$=min]').val('-544');
+ $('input[id$=minMax]').val('-5');
+ $('input[id$=notEmpty]').val('');
+ $('input[id$=notNull]').val('');
+ $('input[id$=pattern]').val('@@@');
+ $('input[id$=custom]').val('@@@');
+ $('input[id$=past]').val(inFuture.format("d mmm
yyyy"));
+ $('input[id$=future]').val(inPast.format("d mmm
yyyy"));
+ $('input[id$=stringSize]').val('JSF 2');
+ $('input[value=A]')[0].checked=false
+ $('input[value=B]')[0].checked=false
+ $('input[value=C]')[0].checked=false
+ $('input[value=D]')[0].checked=false
+ $('input[value=E]')[0].checked=false
+ $('input[value=F]')[0].checked=true
+ }
+ </script>
+
+ <input id="setCorrectValuesButton" type="button"
value="set correct values" onclick="setCorrectValues()"/>
+ <input id="setWrongValuesButton" type="button"
value="set wrong values" onclick="setWrongValues()"/>
+
+ <h:panelGrid columns="3">
+
+ <h:outputLabel for="assertTrue"
value="#{assertTrueBean.description}" />
+ <h:selectBooleanCheckbox id="assertTrue"
value="#{assertTrueBean.value}" label="#{assertTrueBean.label}" >
+ <rich:validator />
+ </h:selectBooleanCheckbox>
+ <rich:message id="assertTrueMsg" for="assertTrue"
/>
+
+ <h:outputLabel for="assertFalse"
value="#{assertFalseBean.description}" />
+ <h:selectBooleanCheckbox id="assertFalse"
value="#{assertFalseBean.value}" label="#{assertFalseBean.label}"
>
+ <rich:validator />
+ </h:selectBooleanCheckbox>
+ <rich:message id="assertFalseMsg"
for="assertFalse" />
+
+ <h:outputLabel for="decimalMinMax"
value="#{decimalMinMaxBean.description}" />
+ <h:inputText id="decimalMinMax"
value="#{decimalMinMaxBean.value}" label="#{decimalMinMaxBean.label}"
+ converter="#{decimalMinMaxBean.converter}">
+ <rich:validator />
+ </h:inputText>
+ <rich:message id="decimalMinMaxMsg"
for="decimalMinMax" />
+
+ <h:outputLabel for="digits"
value="#{digitsBean.description}" />
+ <h:inputText id="digits"
value="#{digitsBean.value}" label="#{digitsBean.label}"
converter="#{digitsBean.converter}">
+ <rich:validator />
+ </h:inputText>
+ <rich:message id="digitsMsg" for="digits" />
+
+ <h:outputLabel for="max"
value="#{maxBean.description}" />
+ <h:inputText id="max" value="#{maxBean.value}"
label="#{maxBean.label}" converter="#{maxBean.converter}">
+ <rich:validator />
+ </h:inputText>
+ <rich:message id="maxMsg" for="max" />
+
+ <h:outputLabel for="min"
value="#{minBean.description}" />
+ <h:inputText id="min" value="#{minBean.value}"
label="#{minBean.label}" converter="#{minBean.converter}">
+ <rich:validator />
+ </h:inputText>
+ <rich:message id="minMsg" for="min" />
+
+ <h:outputLabel for="minMax"
value="#{minMaxBean.description}" />
+ <h:inputText id="minMax"
value="#{minMaxBean.value}" label="#{minMaxBean.label}"
converter="#{minMaxBean.converter}">
+ <rich:validator />
+ </h:inputText>
+ <rich:message id="minMaxMsg" for="minMax" />
+
+ <h:outputLabel for="notEmpty"
value="#{notEmptyBean.description} Xš" />
+ <h:inputText id="notEmpty"
value="#{notEmptyBean.value}" label="#{notEmptyBean.label}" >
+ <rich:validator />
+ </h:inputText>
+ <rich:message id="notEmptyMsg" for="notEmpty"
/>
+
+ <h:outputLabel for="notNull"
value="#{notNullBean.description}" />
+ <h:inputText id="notNull"
value="#{notNullBean.value}" label="#{notNullBean.label}"
converter="emptyStringToNullConverter">
+ <rich:validator />
+ </h:inputText>
+ <rich:message id="notNullMsg" for="notNull" />
+
+ <h:outputLabel for="pattern"
value="#{patternBean.description}" />
+ <h:inputText id="pattern"
value="#{patternBean.value}" label="#{patternBean.label}"
converter="#{patternBean.converter}">
+ <rich:validator />
+ </h:inputText>
+ <rich:message id="patternMsg" for="pattern" />
+
+ <h:outputLabel for="custom" value="custom validator,
RichFaces" />
+ <h:inputText id="custom"
value="#{richValidatorBean.stringValue}" label="custom">
+ <f:validator
validatorId="org.richfaces.StringRichFacesValidator"/>
+ <rich:validator />
+ </h:inputText>
+ <rich:message id="customMsg" for="custom" />
+
+ <h:outputLabel for="past"
value="#{pastBean.description}" />
+ <h:inputText id="past" value="#{pastBean.value}"
label="#{pastBean.label}" >
+ <f:convertDateTime pattern="d MMM yyyy"/>
+ <rich:validator />
+ </h:inputText>
+ <rich:message id="pastMsg" for="past" />
+
+ <h:outputLabel for="future"
value="#{futureBean.description}" />
+ <h:inputText id="future"
value="#{futureBean.value}" label="#{futureBean.label}" >
+ <f:convertDateTime pattern="d MMM yyyy"/>
+ <rich:validator />
+ </h:inputText>
+ <rich:message id="futureMsg" for="future" />
+
+ <h:outputLabel for="stringSize"
value="#{stringSizeBean.description}" />
+ <h:inputText id="stringSize"
value="#{stringSizeBean.value}" label="#{stringSizeBean.label}" >
+ <rich:validator />
+ </h:inputText>
+ <rich:message id="stringSizeMsg" for="stringSize"
/>
+
+ <h:outputLabel for="size"
value="#{sizeBean.description}" />
+ <h:selectManyCheckbox id="size"
value="#{sizeBean.value}" label="#{sizeBean.label}" >
+ <f:selectItem itemValue="A"
itemLabel="A"/>
+ <f:selectItem itemValue="B"
itemLabel="B"/>
+ <f:selectItem itemValue="C"
itemLabel="C"/>
+ <f:selectItem itemValue="D"
itemLabel="D"/>
+ <f:selectItem itemValue="E"
itemLabel="E"/>
+ <f:selectItem itemValue="F"
itemLabel="F"/>
+ <rich:validator />
+ </h:selectManyCheckbox>
+ <rich:message id="sizeMsg" for="size" />
+ </h:panelGrid>
+
+ <br/>
+
+ <h:commandButton id="hButton" value="h:commandButton"
style="margin-right: 10px;"/>
+ <a4j:commandButton id="a4jButton"
value="a4j:commandButton"/>
+
+ <br/>
+ <rich:messages id="msgs"/>
+ </ui:define>
+
+ <ui:define name="outOfTemplateAfter">
+ </ui:define>
+
+ </ui:composition>
+</html>
\ No newline at end of file