Author: jjamrich
Date: 2011-04-26 04:52:29 -0400 (Tue, 26 Apr 2011)
New Revision: 22440
Added:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichGraphValidatorBean.java
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/groups/
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/groups/ValidationGroup1.java
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/groups/ValidationGroup2.java
modules/tests/metamer/trunk/application/src/main/resources/org/richfaces/tests/metamer/bean/RichGraphValidatorBean.properties
modules/tests/metamer/trunk/application/src/main/webapp/components/richGraphValidator/
modules/tests/metamer/trunk/application/src/main/webapp/components/richGraphValidator/jsr303.xhtml
modules/tests/metamer/trunk/application/src/main/webapp/components/richGraphValidator/list.xhtml
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichBean.java
Log:
Add support for test rich:GraphValidator
Add page with jsf303 validator
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichBean.java
===================================================================
---
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichBean.java 2011-04-21
17:59:08 UTC (rev 22439)
+++
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichBean.java 2011-04-26
08:52:29 UTC (rev 22440)
@@ -78,6 +78,7 @@
@PostConstruct
public void init() {
logger = LoggerFactory.getLogger(RichBean.class);
+ logger.info("initializing bean " + getClass().getName());
createSkinList();
createComponentsMap();
@@ -136,6 +137,7 @@
components.put("richExtendedDataTable", "Rich Extended Data
Table");
components.put("richFileUpload", "Rich File Upload");
components.put("richFunctions", "Rich Functions");
+ components.put("richGraphValidator", "Rich Graph
Validator");
components.put("richHashParam", "Rich Hash Parameter");
components.put("richInplaceInput", "Rich Inplace Input");
components.put("richInplaceSelect", "Rich Inplace Select");
Added:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichGraphValidatorBean.java
===================================================================
---
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichGraphValidatorBean.java
(rev 0)
+++
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichGraphValidatorBean.java 2011-04-26
08:52:29 UTC (rev 22440)
@@ -0,0 +1,115 @@
+/*******************************************************************************
+ * 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.
+ *******************************************************************************/
+package org.richfaces.tests.metamer.bean;
+
+import java.io.Serializable;
+
+import javax.annotation.PostConstruct;
+import javax.faces.application.FacesMessage;
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.ViewScoped;
+import javax.faces.context.FacesContext;
+import javax.validation.constraints.AssertTrue;
+import javax.validation.constraints.Size;
+import javax.validation.groups.Default;
+
+import org.richfaces.component.UIGraphValidator;
+import org.richfaces.tests.metamer.Attributes;
+import org.richfaces.tests.metamer.validation.groups.ValidationGroup1;
+import org.richfaces.tests.metamer.validation.groups.ValidationGroup2;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Managed Bean for rich:graphValidator
+ *
+ * @author <a href="mailto:jjamrich@redhat.com">Jan Jamrich</a>
+ * @version $Revision$
+ */
+@ManagedBean(name="richGraphValidatorBean")
+@ViewScoped
+public class RichGraphValidatorBean implements Serializable, Cloneable {
+
+ /** Generated UID */
+ private static final long serialVersionUID = -960575870621302059L;
+ private static Logger logger;
+ private Attributes attributes;
+
+ @Size(min = 5, max = 15, message = "Wrong size for password")
+ private String password;
+ @Size(min = 5, max = 15, message = "Wrong size for password")
+ private String passwordConfirm;
+
+ @PostConstruct
+ public void init(){
+ logger = LoggerFactory.getLogger(getClass());
+ logger.info("initializing bean " + getClass().getName());
+ attributes =
Attributes.getComponentAttributesFromFacesConfig(UIGraphValidator.class, getClass());
+
+ attributes.setAttribute("rendered", true);
+ attributes.setAttribute("type",
"org.richfaces.BeanValidator");
+ }
+
+ @AssertTrue(message = "Different passwords entered! [Default Group]")
+ public boolean isPasswordsEquals() {
+ return password.equals(passwordConfirm);
+ }
+
+ @AssertTrue(message = "Different passwords entered! [G1]",
groups={ValidationGroup1.class})
+ public boolean isRovnakeHesla() {
+ return password.equals(passwordConfirm);
+ }
+
+ @AssertTrue(message = "Different passwords entered! [G2 + Default Group]",
groups = {ValidationGroup2.class,Default.class})
+ public boolean isPokusUspesny() {
+ return password.equals(passwordConfirm);
+ }
+
+ public void storeNewPassword() {
+ FacesContext.getCurrentInstance().addMessage(null,
+ new FacesMessage(FacesMessage.SEVERITY_INFO, "Succesfully
changed!", "Succesfully changed!"));
+ }
+
+ public Attributes getAttributes() {
+ return attributes;
+ }
+
+ public void setAttributes(Attributes attributes) {
+ this.attributes = attributes;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public String getPasswordConfirm() {
+ return passwordConfirm;
+ }
+
+ public void setPasswordConfirm(String passwordConfirm) {
+ this.passwordConfirm = passwordConfirm;
+ }
+}
Added:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/groups/ValidationGroup1.java
===================================================================
---
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/groups/ValidationGroup1.java
(rev 0)
+++
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/groups/ValidationGroup1.java 2011-04-26
08:52:29 UTC (rev 22440)
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * 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.
+ *******************************************************************************/
+package org.richfaces.tests.metamer.validation.groups;
+
+
+/**
+ * Validation Group for groups attribute testing
+ *
+ * @author <a href="mailto:jjamrich@redhat.com">Jan Jamrich</a>
+ * @version $Revision$
+ */
+public class ValidationGroup1 {
+
+}
Added:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/groups/ValidationGroup2.java
===================================================================
---
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/groups/ValidationGroup2.java
(rev 0)
+++
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/validation/groups/ValidationGroup2.java 2011-04-26
08:52:29 UTC (rev 22440)
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * 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.
+ *******************************************************************************/
+package org.richfaces.tests.metamer.validation.groups;
+
+/**
+ * Validation Group for groups attribute testing
+ *
+ * @author <a href="mailto:jjamrich@redhat.com">Jan Jamrich</a>
+ * @version $Revision$
+ */
+public interface ValidationGroup2 {
+
+}
Added:
modules/tests/metamer/trunk/application/src/main/resources/org/richfaces/tests/metamer/bean/RichGraphValidatorBean.properties
===================================================================
---
modules/tests/metamer/trunk/application/src/main/resources/org/richfaces/tests/metamer/bean/RichGraphValidatorBean.properties
(rev 0)
+++
modules/tests/metamer/trunk/application/src/main/resources/org/richfaces/tests/metamer/bean/RichGraphValidatorBean.properties 2011-04-26
08:52:29 UTC (rev 22440)
@@ -0,0 +1,2 @@
+attr.type.BeanValidator=org.richfaces.BeanValidator
+
Added:
modules/tests/metamer/trunk/application/src/main/webapp/components/richGraphValidator/jsr303.xhtml
===================================================================
---
modules/tests/metamer/trunk/application/src/main/webapp/components/richGraphValidator/jsr303.xhtml
(rev 0)
+++
modules/tests/metamer/trunk/application/src/main/webapp/components/richGraphValidator/jsr303.xhtml 2011-04-26
08:52:29 UTC (rev 22440)
@@ -0,0 +1,135 @@
+<?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"
+
xmlns:metamer="http://java.sun.com/jsf/composite/metamer">
+
+<!--
+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() {
+ $('input[id$=pass1]').val('rfvokm334lafd');
+ $('input[id$=conf1]').val('rfvokm334lafd');
+ }
+
+ function setWrongValues() {
+ $('input[id$=pass1]').val('rfvdthrfd');
+ $('input[id$=conf1]').val('dsararaAqa');
+ }
+ </script>
+
+ <h:form>
+ <input id="setCorrectValuesButton" type="button"
value="set correct values" onclick="setCorrectValues()"/>
+ <input id="setWrongValuesButton" type="button"
value="set wrong values" onclick="setWrongValues()"/>
+
+ <br/>
+
+ <ui:fragment
rendered="#{richGraphValidatorBean.attributes['summary'].value==null
+ || richGraphValidatorBean.attributes['summary'].value==''}"
>
+ <rich:graphValidator id="gv1"
+ value="#{richGraphValidatorBean}"
+
groups="#{richGraphValidatorBean.attributes['groups'].value}"
+ type="#{richGraphValidatorBean.attributes['type'].value}"
+
rendered="#{richGraphValidatorBean.attributes['rendered'].value}"
>
+ <rich:panel header="Change password" style="width:500px">
+ <rich:messages for="gv1" />
+ <rich:messages globalOnly="true" />
+ <h:panelGrid columns="3">
+ <h:outputText value="Enter new password:" />
+ <h:inputSecret value="#{richGraphValidatorBean.password}"
id="pass1" />
+ <rich:message for="pass1" />
+ <h:outputText value="Confirm the new password:" />
+ <h:inputSecret value="#{richGraphValidatorBean.passwordConfirm}"
id="conf1" />
+ <rich:message for="conf1" />
+ </h:panelGrid>
+ <a4j:commandButton value="Store changes"
+ action="#{richGraphValidatorBean.storeNewPassword}" />
+ </rich:panel>
+ </rich:graphValidator>
+ </ui:fragment>
+
+ <ui:fragment
rendered="#{richGraphValidatorBean.attributes['summary'].value!=null
+ &&
richGraphValidatorBean.attributes['summary'].value!=''}" >
+ <rich:graphValidator id="gv2"
+ value="#{richGraphValidatorBean}"
+
groups="#{richGraphValidatorBean.attributes['groups'].value}"
+
rendered="#{richGraphValidatorBean.attributes['rendered'].value}"
+
summary="#{richGraphValidatorBean.attributes['summary'].value}"
+ type="#{richGraphValidatorBean.attributes['type'].value}"
>
+ <rich:panel header="Change password" style="width:500px">
+ <rich:messages for="gv2" />
+ <rich:messages globalOnly="true" />
+ <h:panelGrid columns="3">
+ <h:outputText value="Enter new password:" />
+ <h:inputSecret value="#{richGraphValidatorBean.password}"
+ id="pass2" />
+ <rich:message for="pass2" />
+ <h:outputText value="Confirm the new password:" />
+ <h:inputSecret value="#{richGraphValidatorBean.passwordConfirm}"
+ id="conf2" />
+ <rich:message for="conf2" />
+ </h:panelGrid>
+ <a4j:commandButton value="Store changes"
+ action="#{richGraphValidatorBean.storeNewPassword}" />
+ </rich:panel>
+ </rich:graphValidator>
+ </ui:fragment>
+
+ </h:form>
+
+ <br />
+ <rich:messages id="msgs" value="#{richGraphValidatorBean}"
/>
+
+ </ui:define>
+
+ <ui:define name="outOfTemplateAfter">
+ <metamer:attributes value="#{richGraphValidatorBean.attributes}"
+ id="attributes" />
+ </ui:define>
+
+</ui:composition>
+</html>
\ No newline at end of file
Added:
modules/tests/metamer/trunk/application/src/main/webapp/components/richGraphValidator/list.xhtml
===================================================================
---
modules/tests/metamer/trunk/application/src/main/webapp/components/richGraphValidator/list.xhtml
(rev 0)
+++
modules/tests/metamer/trunk/application/src/main/webapp/components/richGraphValidator/list.xhtml 2011-04-26
08:52:29 UTC (rev 22440)
@@ -0,0 +1,42 @@
+<?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:ui="http://java.sun.com/jsf/facelets"
+
xmlns:metamer="http://java.sun.com/jsf/composite/metamer">
+
+ <!--
+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/list.xhtml">
+
+ <ui:define name="pageTitle">Rich Graph
Validator</ui:define>
+
+ <ui:define name="links">
+
+ <metamer:testPageLink id="jsr303" outcome="jsr303"
value="JSR-303 Bean Validation">
+ Page containing input with JSR-303 validator within
<b>rich:graphValidator</b>
+ </metamer:testPageLink>
+
+ </ui:define>
+
+ </ui:composition>
+
+</html>