Author: jjamrich
Date: 2011-05-23 09:15:31 -0400 (Mon, 23 May 2011)
New Revision: 22503
Added:
modules/tests/metamer/trunk/application/src/main/webapp/components/richAutocomplete/jsr303.xhtml
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/rich/RichAutocompleteBean.java
modules/tests/metamer/trunk/application/src/main/webapp/components/richAutocomplete/list.xhtml
Log:
rfpl-1241: test standard JSR-303 validators with autocomplete
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/rich/RichAutocompleteBean.java
===================================================================
---
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/rich/RichAutocompleteBean.java 2011-05-23
13:14:55 UTC (rev 22502)
+++
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/rich/RichAutocompleteBean.java 2011-05-23
13:15:31 UTC (rev 22503)
@@ -30,7 +30,10 @@
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped;
+import javax.validation.constraints.Pattern;
+import javax.validation.constraints.Size;
+import org.hibernate.validator.constraints.NotEmpty;
import org.richfaces.component.UIAutocomplete;
import org.richfaces.tests.metamer.Attributes;
import org.richfaces.tests.metamer.model.Capital;
@@ -55,6 +58,12 @@
private Attributes ajaxAttributes;
@ManagedProperty(value = "#{model.capitals}")
private List<Capital> capitals;
+
+ // properties for jsr303 validations
+ private String value1;
+ private String value2;
+ private String value3;
+ private String value4;
/**
* Initializes the managed bean.
@@ -114,4 +123,40 @@
public void setCapitals(List<Capital> capitals) {
this.capitals = capitals;
}
+
+ @NotEmpty
+ public String getValue1() {
+ return value1;
+ }
+
+ public void setValue1(String value1) {
+ this.value1 = value1;
+ }
+
+ @Pattern(regexp = "[a-z].*")
+ public String getValue2() {
+ return value2;
+ }
+
+ public void setValue2(String value2) {
+ this.value2 = value2;
+ }
+
+ @Size(min = 3, max = 6)
+ public String getValue3() {
+ return value3;
+ }
+
+ public void setValue3(String value3) {
+ this.value3 = value3;
+ }
+
+ public String getValue4() {
+ return value4;
+ }
+
+ public void setValue4(String value4) {
+ this.value4 = value4;
+ }
+
}
Added:
modules/tests/metamer/trunk/application/src/main/webapp/components/richAutocomplete/jsr303.xhtml
===================================================================
---
modules/tests/metamer/trunk/application/src/main/webapp/components/richAutocomplete/jsr303.xhtml
(rev 0)
+++
modules/tests/metamer/trunk/application/src/main/webapp/components/richAutocomplete/jsr303.xhtml 2011-05-23
13:15:31 UTC (rev 22503)
@@ -0,0 +1,98 @@
+<?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:rich="http://richfaces.org/rich"
xmlns:a4j="http://richfaces.org/a4j">
+
+ <!--
+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="component">
+ <h:commandButton id="hButton" value="h:commandButton"
style="margin-right: 10px;"/>
+ <a4j:commandButton id="a4jButton"
value="a4j:commandButton"/>
+ <br/><br/>
+
+ <h:panelGrid columns="3">
+ not empty
+ <rich:autocomplete id="input1"
value="#{richAutocompleteBean.value1}" >
+ <a4j:ajax event="change"
render="output1"/>
+ </rich:autocomplete>
+ <rich:message id="inputMsg1" for="input1"/>
+
+ pattern [a-z].*
+ <rich:autocomplete id="input2"
+
defaultLabel="#{richAutocompleteBean.attributes['defaultLabel'].value}"
+ value="#{richAutocompleteBean.value2}"
+ >
+ <a4j:ajax event="change"
render="output2"/>
+ </rich:autocomplete>
+ <rich:message id="inputMsg2" for="input2"/>
+
+ size 3-6
+ <rich:autocomplete id="input3"
+
defaultLabel="#{richAutocompleteBean.attributes['defaultLabel'].value}"
+ value="#{richAutocompleteBean.value3}"
+ >
+ <a4j:ajax event="change"
render="output3"/>
+ </rich:autocomplete>
+ <rich:message id="inputMsg3" for="input3"/>
+
+ custom (RichFaces)
+ <rich:autocomplete id="input4"
+
defaultLabel="#{richAutocompleteBean.attributes['defaultLabel'].value}"
+ value="#{richAutocompleteBean.value4}"
+ >
+ <f:validator
validatorId="org.richfaces.StringRichFacesValidator"/>
+ <a4j:ajax event="change"
render="output4"/>
+ </rich:autocomplete>
+ <rich:message id="inputMsg4" for="input4"/>
+
+ </h:panelGrid>
+ <br/><br/>
+
+ <h:panelGrid columns="2">
+ output1
+ <h:outputText id="output1"
value="#{richAutocompleteBean.value1}"/>
+ output2
+ <h:outputText id="output2"
value="#{richAutocompleteBean.value2}"/>
+ output3
+ <h:outputText id="output3"
value="#{richAutocompleteBean.value3}"/>
+ output4
+ <h:outputText id="output4"
value="#{richAutocompleteBean.value4}"/>
+ </h:panelGrid>
+
+ </ui:define>
+
+ <ui:define name="outOfTemplateAfter">
+ </ui:define>
+
+ </ui:composition>
+</html>
\ No newline at end of file
Modified:
modules/tests/metamer/trunk/application/src/main/webapp/components/richAutocomplete/list.xhtml
===================================================================
---
modules/tests/metamer/trunk/application/src/main/webapp/components/richAutocomplete/list.xhtml 2011-05-23
13:14:55 UTC (rev 22502)
+++
modules/tests/metamer/trunk/application/src/main/webapp/components/richAutocomplete/list.xhtml 2011-05-23
13:15:31 UTC (rev 22503)
@@ -35,6 +35,10 @@
Simple page that contains <b>rich:autocomplete</b> (with
model containing capitals) and
input boxes for all its attributes.
</metamer:testPageLink>
+
+ <metamer:testPageLink id="jsr303" outcome="jsr303"
value="JSR-303 Bean Validation">
+ Simple page that contains some <b>rich:autocomplete</b>s with
various JSR-303 validators.
+ </metamer:testPageLink>
</ui:define>