Author: ppitonak(a)redhat.com
Date: 2011-03-10 09:49:25 -0500 (Thu, 10 Mar 2011)
New Revision: 22135
Added:
modules/tests/metamer/trunk/application/src/main/webapp/components/richInplaceSelect/csv.xhtml
modules/tests/metamer/trunk/application/src/main/webapp/components/richInplaceSelect/jsr303.xhtml
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichInplaceSelectBean.java
modules/tests/metamer/trunk/application/src/main/webapp/components/richInplaceSelect/list.xhtml
Log:
added validation samples for rich:inplaceSelect
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichInplaceSelectBean.java
===================================================================
---
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichInplaceSelectBean.java 2011-03-10
14:49:06 UTC (rev 22134)
+++
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichInplaceSelectBean.java 2011-03-10
14:49:25 UTC (rev 22135)
@@ -30,6 +30,9 @@
import javax.faces.bean.ViewScoped;
import javax.faces.event.ValueChangeEvent;
import javax.faces.model.SelectItem;
+import javax.validation.constraints.Pattern;
+import javax.validation.constraints.Size;
+import org.hibernate.validator.constraints.NotEmpty;
import org.richfaces.component.UIInplaceSelect;
import org.richfaces.tests.metamer.Attributes;
@@ -53,6 +56,11 @@
// FIXME: @ManagedProperty(value = "#{model.capitals}")
private List<Capital> capitals = Model.unmarshallCapitals();
private List<SelectItem> capitalsOptions = null;
+ private List<SelectItem> validationOptions = null;
+ private String value1;
+ private String value2;
+ private String value3;
+ private String value4;
/**
* Initializes the managed bean.
@@ -63,9 +71,15 @@
logger.debug("initializing bean " + getClass().getName());
capitalsOptions = new ArrayList<SelectItem>();
+ validationOptions = new ArrayList<SelectItem>();
for (Capital capital : capitals) {
capitalsOptions.add(new SelectItem(capital.getState(), capital.getState()));
+ validationOptions.add(new SelectItem(capital.getState(),
capital.getState()));
}
+ validationOptions.add(new SelectItem("@@", "@@"));
+ validationOptions.add(new SelectItem("", ""));
+ validationOptions.add(new SelectItem("RichFaces",
"RichFaces"));
+ validationOptions.add(new SelectItem("richfaces",
"richfaces"));
attributes =
Attributes.getComponentAttributesFromFacesConfig(UIInplaceSelect.class, getClass());
@@ -114,6 +128,49 @@
this.capitalsOptions = capitalsOptions;
}
+ public List<SelectItem> getValidationOptions() {
+ return validationOptions;
+ }
+
+ public void setValidationOptions(List<SelectItem> validationOptions) {
+ this.validationOptions = validationOptions;
+ }
+
+ @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;
+ }
+
public void listener(ValueChangeEvent event) {
RichBean.logToPage("* value changed: " + event.getOldValue() + "
-> " + event.getNewValue());
}
Added:
modules/tests/metamer/trunk/application/src/main/webapp/components/richInplaceSelect/csv.xhtml
===================================================================
---
modules/tests/metamer/trunk/application/src/main/webapp/components/richInplaceSelect/csv.xhtml
(rev 0)
+++
modules/tests/metamer/trunk/application/src/main/webapp/components/richInplaceSelect/csv.xhtml 2011-03-10
14:49:25 UTC (rev 22135)
@@ -0,0 +1,104 @@
+<?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:panelGrid columns="3">
+ not empty
+ <rich:inplaceSelect id="input1"
+
defaultLabel="#{richInplaceSelectBean.attributes['defaultLabel'].value}"
+ value="#{richInplaceSelectBean.value1}"
+ >
+ <f:selectItems
value="#{richInplaceSelectBean.validationOptions}" />
+ <a4j:ajax event="change"
render="output1"/>
+ <rich:validator event="change"/>
+ </rich:inplaceSelect>
+ <rich:message id="inputMsg1" for="input1"/>
+
+ pattern [a-z].*
+ <rich:inplaceSelect id="input2"
+
defaultLabel="#{richInplaceSelectBean.attributes['defaultLabel'].value}"
+ value="#{richInplaceSelectBean.value2}"
+ >
+ <f:selectItems
value="#{richInplaceSelectBean.validationOptions}" />
+ <a4j:ajax event="change"
render="output2"/>
+ <rich:validator event="change"/>
+ </rich:inplaceSelect>
+ <rich:message id="inputMsg2" for="input2"/>
+
+ size 3-6
+ <rich:inplaceSelect id="input3"
+
defaultLabel="#{richInplaceSelectBean.attributes['defaultLabel'].value}"
+ value="#{richInplaceSelectBean.value3}"
+ >
+ <f:selectItems
value="#{richInplaceSelectBean.validationOptions}" />
+ <a4j:ajax event="change"
render="output3"/>
+ <rich:validator event="change"/>
+ </rich:inplaceSelect>
+ <rich:message id="inputMsg3" for="input3"/>
+
+ custom (RichFaces)
+ <rich:inplaceSelect id="input4"
+
defaultLabel="#{richInplaceSelectBean.attributes['defaultLabel'].value}"
+ value="#{richInplaceSelectBean.value4}"
+ >
+ <f:selectItems
value="#{richInplaceSelectBean.validationOptions}" />
+ <f:validator
validatorId="org.richfaces.StringRichFacesValidator"/>
+ <a4j:ajax event="change"
render="output4"/>
+ <rich:validator event="change"/>
+ </rich:inplaceSelect>
+ <rich:message id="inputMsg4" for="input4"/>
+
+ </h:panelGrid>
+ <br/><br/>
+
+ <h:panelGrid columns="2">
+ output1
+ <h:outputText id="output1"
value="#{richInplaceSelectBean.value1}"/>
+ output2
+ <h:outputText id="output2"
value="#{richInplaceSelectBean.value2}"/>
+ output3
+ <h:outputText id="output3"
value="#{richInplaceSelectBean.value3}"/>
+ output4
+ <h:outputText id="output4"
value="#{richInplaceSelectBean.value4}"/>
+ </h:panelGrid>
+ </ui:define>
+
+ <ui:define name="outOfTemplateAfter">
+ </ui:define>
+
+ </ui:composition>
+</html>
\ No newline at end of file
Added:
modules/tests/metamer/trunk/application/src/main/webapp/components/richInplaceSelect/jsr303.xhtml
===================================================================
---
modules/tests/metamer/trunk/application/src/main/webapp/components/richInplaceSelect/jsr303.xhtml
(rev 0)
+++
modules/tests/metamer/trunk/application/src/main/webapp/components/richInplaceSelect/jsr303.xhtml 2011-03-10
14:49:25 UTC (rev 22135)
@@ -0,0 +1,104 @@
+<?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:inplaceSelect id="input1"
+
defaultLabel="#{richInplaceSelectBean.attributes['defaultLabel'].value}"
+ value="#{richInplaceSelectBean.value1}"
+ >
+ <f:selectItems
value="#{richInplaceSelectBean.validationOptions}" />
+ <a4j:ajax event="change"
render="output1"/>
+ </rich:inplaceSelect>
+ <rich:message id="inputMsg1" for="input1"/>
+
+ pattern [a-z].*
+ <rich:inplaceSelect id="input2"
+
defaultLabel="#{richInplaceSelectBean.attributes['defaultLabel'].value}"
+ value="#{richInplaceSelectBean.value2}"
+ >
+ <f:selectItems
value="#{richInplaceSelectBean.validationOptions}" />
+ <a4j:ajax event="change"
render="output2"/>
+ </rich:inplaceSelect>
+ <rich:message id="inputMsg2" for="input2"/>
+
+ size 3-6
+ <rich:inplaceSelect id="input3"
+
defaultLabel="#{richInplaceSelectBean.attributes['defaultLabel'].value}"
+ value="#{richInplaceSelectBean.value3}"
+ >
+ <f:selectItems
value="#{richInplaceSelectBean.validationOptions}" />
+ <a4j:ajax event="change"
render="output3"/>
+ </rich:inplaceSelect>
+ <rich:message id="inputMsg3" for="input3"/>
+
+ custom (RichFaces)
+ <rich:inplaceSelect id="input4"
+
defaultLabel="#{richInplaceSelectBean.attributes['defaultLabel'].value}"
+ value="#{richInplaceSelectBean.value4}"
+ >
+ <f:selectItems
value="#{richInplaceSelectBean.validationOptions}" />
+ <f:validator
validatorId="org.richfaces.StringRichFacesValidator"/>
+ <a4j:ajax event="change"
render="output4"/>
+ </rich:inplaceSelect>
+ <rich:message id="inputMsg4" for="input4"/>
+
+ </h:panelGrid>
+ <br/><br/>
+
+ <h:panelGrid columns="2">
+ output1
+ <h:outputText id="output1"
value="#{richInplaceSelectBean.value1}"/>
+ output2
+ <h:outputText id="output2"
value="#{richInplaceSelectBean.value2}"/>
+ output3
+ <h:outputText id="output3"
value="#{richInplaceSelectBean.value3}"/>
+ output4
+ <h:outputText id="output4"
value="#{richInplaceSelectBean.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/richInplaceSelect/list.xhtml
===================================================================
---
modules/tests/metamer/trunk/application/src/main/webapp/components/richInplaceSelect/list.xhtml 2011-03-10
14:49:06 UTC (rev 22134)
+++
modules/tests/metamer/trunk/application/src/main/webapp/components/richInplaceSelect/list.xhtml 2011-03-10
14:49:25 UTC (rev 22135)
@@ -39,6 +39,14 @@
Simple page that contains <b>rich:inplaceSelect</b> with
f:ajax and input boxes for all its attributes.
</metamer:testPageLink>
+ <metamer:testPageLink id="csv" outcome="csv"
value="Client Side Validation">
+ Simple page that contains 4 <b>rich:inplaceSelect</b>s
testing client-side validation.
+ </metamer:testPageLink>
+
+ <metamer:testPageLink id="jsr303" outcome="jsr303"
value="JSR-303 Bean Validation">
+ Page containing 4 <b>rich:inplaceSelect</b>s with various
JSR-303 validators.
+ </metamer:testPageLink>
+
</ui:define>
</ui:composition>