Author: alexsmirnov
Date: 2008-08-04 19:37:51 -0400 (Mon, 04 Aug 2008)
New Revision: 9905
Added:
trunk/samples/seamEAR/ejbs/src/main/resources/seamEAR-ds.xml
trunk/ui/beanValidator/src/main/java/org/richfaces/taglib/BeanValidatorHandler.java
trunk/ui/beanValidator/src/main/java/org/richfaces/taglib/BeanValidatorTag.java
Removed:
trunk/samples/seamEAR/ear/src/main/application/META-INF/seamEAR-ds.xml
Modified:
trunk/cdk/generator/src/main/resources/META-INF/templates12/validatorTag.vm
trunk/samples/beanValidatorSample/src/main/java/org/richfaces/LengthBean.java
trunk/samples/beanValidatorSample/src/main/java/org/richfaces/MaxBean.java
trunk/samples/beanValidatorSample/src/main/java/org/richfaces/MinBean.java
trunk/samples/beanValidatorSample/src/main/java/org/richfaces/MinMaxBean.java
trunk/samples/beanValidatorSample/src/main/java/org/richfaces/NotEmptyBean.java
trunk/samples/beanValidatorSample/src/main/java/org/richfaces/NotNullBean.java
trunk/samples/beanValidatorSample/src/main/java/org/richfaces/Validable.java
trunk/samples/beanValidatorSample/src/main/webapp/pages/index.jsp
trunk/samples/beanValidatorSample/src/main/webapp/pages/index.xhtml
trunk/samples/seamEAR/ejbs/src/main/java/org/richfaces/seam/StatelessBean.java
trunk/samples/seamEAR/projects/logging/src/main/java/org/richfaces/demo/Log.java
trunk/ui/beanValidator/src/main/config/component/beanValidator.xml
trunk/ui/beanValidator/src/main/java/org/richfaces/taglib/AjaxValidatorHandler.java
trunk/ui/beanValidator/src/main/java/org/richfaces/taglib/AjaxValidatorTagBase.java
trunk/ui/beanValidator/src/main/java/org/richfaces/validator/FacesBeanValidator.java
Log:
https://jira.jboss.org/jira/browse/RF-3547 Implement "summary" attribute for an
bean/ajavValidator.
Modified: trunk/cdk/generator/src/main/resources/META-INF/templates12/validatorTag.vm
===================================================================
--- trunk/cdk/generator/src/main/resources/META-INF/templates12/validatorTag.vm 2008-08-04
23:15:16 UTC (rev 9904)
+++ trunk/cdk/generator/src/main/resources/META-INF/templates12/validatorTag.vm 2008-08-04
23:37:51 UTC (rev 9905)
@@ -8,12 +8,11 @@
import $import ;
#end
import javax.faces.component.UIComponent;
-import javax.faces.webapp.UIComponentTag;
import javax.faces.validator.Validator;
import org.apache.commons.beanutils.ConvertUtils;
import javax.faces.context.FacesContext;
import javax.servlet.jsp.JspException;
-import javax.faces.el.ValueBinding;
+import javax.el.ValueExpression;
import ${validator.classname};
public class $tag.simpleClassName extends $tag.superclass {
Modified: trunk/samples/beanValidatorSample/src/main/java/org/richfaces/LengthBean.java
===================================================================
---
trunk/samples/beanValidatorSample/src/main/java/org/richfaces/LengthBean.java 2008-08-04
23:15:16 UTC (rev 9904)
+++
trunk/samples/beanValidatorSample/src/main/java/org/richfaces/LengthBean.java 2008-08-04
23:37:51 UTC (rev 9905)
@@ -51,8 +51,15 @@
}
public String getIntDescription() {
- // TODO Auto-generated method stub
return "Integer Value, no restrictions";
}
+ public String getIntSummary() {
+ return "Invalid user name";
+ }
+
+ public String getTextSummary() {
+ return "Invalid user name";
+ }
+
}
Modified: trunk/samples/beanValidatorSample/src/main/java/org/richfaces/MaxBean.java
===================================================================
--- trunk/samples/beanValidatorSample/src/main/java/org/richfaces/MaxBean.java 2008-08-04
23:15:16 UTC (rev 9904)
+++ trunk/samples/beanValidatorSample/src/main/java/org/richfaces/MaxBean.java 2008-08-04
23:37:51 UTC (rev 9905)
@@ -59,4 +59,14 @@
return "Integer Value, less then 10";
}
+ public String getIntSummary() {
+ // TODO Auto-generated method stub
+ return "Invalid number of items";
+ }
+
+ public String getTextSummary() {
+ // TODO Auto-generated method stub
+ return "Invalid payment card";
+ }
+
}
Modified: trunk/samples/beanValidatorSample/src/main/java/org/richfaces/MinBean.java
===================================================================
--- trunk/samples/beanValidatorSample/src/main/java/org/richfaces/MinBean.java 2008-08-04
23:15:16 UTC (rev 9904)
+++ trunk/samples/beanValidatorSample/src/main/java/org/richfaces/MinBean.java 2008-08-04
23:37:51 UTC (rev 9905)
@@ -56,4 +56,14 @@
return "Integer Value, more then 1";
}
+ public String getIntSummary() {
+ // TODO Auto-generated method stub
+ return "Invalid rooms qty";
+ }
+
+ public String getTextSummary() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
}
Modified: trunk/samples/beanValidatorSample/src/main/java/org/richfaces/MinMaxBean.java
===================================================================
---
trunk/samples/beanValidatorSample/src/main/java/org/richfaces/MinMaxBean.java 2008-08-04
23:15:16 UTC (rev 9904)
+++
trunk/samples/beanValidatorSample/src/main/java/org/richfaces/MinMaxBean.java 2008-08-04
23:37:51 UTC (rev 9905)
@@ -58,4 +58,14 @@
return "Integer Value, valid values from 2 to 10";
}
+ public String getIntSummary() {
+ // TODO Auto-generated method stub
+ return "Invalid price";
+ }
+
+ public String getTextSummary() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
}
Modified: trunk/samples/beanValidatorSample/src/main/java/org/richfaces/NotEmptyBean.java
===================================================================
---
trunk/samples/beanValidatorSample/src/main/java/org/richfaces/NotEmptyBean.java 2008-08-04
23:15:16 UTC (rev 9904)
+++
trunk/samples/beanValidatorSample/src/main/java/org/richfaces/NotEmptyBean.java 2008-08-04
23:37:51 UTC (rev 9905)
@@ -54,4 +54,14 @@
return "Integer Value, no restrictions";
}
+ public String getIntSummary() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getTextSummary() {
+ // TODO Auto-generated method stub
+ return "Invalid password";
+ }
+
}
Modified: trunk/samples/beanValidatorSample/src/main/java/org/richfaces/NotNullBean.java
===================================================================
---
trunk/samples/beanValidatorSample/src/main/java/org/richfaces/NotNullBean.java 2008-08-04
23:15:16 UTC (rev 9904)
+++
trunk/samples/beanValidatorSample/src/main/java/org/richfaces/NotNullBean.java 2008-08-04
23:37:51 UTC (rev 9905)
@@ -53,4 +53,14 @@
return "Integer Value, no restrictions";
}
+ public String getIntSummary() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getTextSummary() {
+ // TODO Auto-generated method stub
+ return "Invalid address";
+ }
+
}
Modified: trunk/samples/beanValidatorSample/src/main/java/org/richfaces/Validable.java
===================================================================
---
trunk/samples/beanValidatorSample/src/main/java/org/richfaces/Validable.java 2008-08-04
23:15:16 UTC (rev 9904)
+++
trunk/samples/beanValidatorSample/src/main/java/org/richfaces/Validable.java 2008-08-04
23:37:51 UTC (rev 9905)
@@ -13,7 +13,9 @@
public String getTextDescription();
+ public String getTextSummary();
+
public int getIntValue();
- public String getIntDescription();
+ public String getIntSummary();
}
Modified: trunk/samples/beanValidatorSample/src/main/webapp/pages/index.jsp
===================================================================
--- trunk/samples/beanValidatorSample/src/main/webapp/pages/index.jsp 2008-08-04 23:15:16
UTC (rev 9904)
+++ trunk/samples/beanValidatorSample/src/main/webapp/pages/index.jsp 2008-08-04 23:37:51
UTC (rev 9905)
@@ -59,6 +59,46 @@
</rich:dataTable>
</v:graphValidator>
</h:form>
+ <h:form id="form2">
+ <h2>Input fields with label and message in the JSF dataTable.
+ Same as above, but fields validated by form submit only.</h2>
+
+ <rich:dataTable value="#{data.beans}" var="bean"
id="table2">
+ <f:facet name="header">
+ <h:outputText
+ value="Validate values in the data table." />
+ </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}">
+ <v:beanValidator summary="#{bean.textSummary}"/>
+ </h:inputText>
+ <rich:message for="text" />
+ </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}">
+ <v:beanValidator summary="#{bean.intSummary}"/>
+ </h:inputText>
+ <rich:message for="intValue" />
+ </h:column>
+ <f:facet name="footer">
+ <h:panelGroup>
+ <h:outputText></h:outputText>
+ <h:commandButton value="Submit all fields"></h:commandButton>
+ </h:panelGroup>
+ </f:facet>
+ </rich:dataTable>
+
+ </h:form>
+
<rich:messages />
</f:view>
</body>
Modified: trunk/samples/beanValidatorSample/src/main/webapp/pages/index.xhtml
===================================================================
--- trunk/samples/beanValidatorSample/src/main/webapp/pages/index.xhtml 2008-08-04
23:15:16 UTC (rev 9904)
+++ trunk/samples/beanValidatorSample/src/main/webapp/pages/index.xhtml 2008-08-04
23:37:51 UTC (rev 9905)
@@ -1,13 +1,12 @@
<!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:f="http://java.sun.com/jsf/core"
-
xmlns:h="http://java.sun.com/jsf/html"
-
xmlns:ui="http://java.sun.com/jsf/facelets"
-
xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
-
xmlns:c="http://java.sun.com/jsp/jstl/core"
-
xmlns:rich="http://richfaces.org/rich"
-
xmlns:v="http://labs.jboss.com/jbossrichfaces/ui/beanValidator"
- >
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
+
xmlns:c="http://java.sun.com/jsp/jstl/core"
+
xmlns:rich="http://richfaces.org/rich"
+
xmlns:v="http://labs.jboss.com/jbossrichfaces/ui/beanValidator"...
<head>
<title>Hibernate validator test</title>
</head>
@@ -15,32 +14,74 @@
<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}">
- <v: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>
- <v:graphValidator value="#{data}" >
- <rich:dataTable value="#{data.beans}" var="bean"
id="table">
+ <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}">
+ <v:ajaxValidator event="onkeyup" summary="Invalid Id"/>
+ </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>
+ <v: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" />
+ <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}">
+ <v:ajaxValidator event="onblur"
+ ajaxListener="#{data.ajaxListener}"
summary="#{bean.textSummary}"/>
+ </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}">
+ <v:ajaxValidator event="onblur"
summary="#{bean.intSummary}"/>
+ </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>
+ </v:graphValidator>
+ </h:form>
+ <h:form id="form2">
+ <h2>Input fields with label and message in the JSF dataTable.
+ Same as above, but fields validated by form submit only.</h2>
+
+ <rich:dataTable value="#{data.beans}" var="bean"
id="table2">
+ <f:facet name="header">
+ <h:outputText
+ value="Validate values in the data table." />
+ </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}">
- <v:ajaxValidator event="onblur"
ajaxListener="#{data.ajaxListener}" />
+ <v:beanValidator summary="Invalid text"/>
</h:inputText>
- <rich:message for="text" showDetail="true"
showSummary="true" />
+ <rich:message for="text" />
</h:column>
<h:column>
<f:facet name="header">
@@ -48,20 +89,20 @@
</f:facet>
<h:outputLabel for="intValue" value="#{bean.intDescription}"
/>
<h:inputText id="intValue" value="#{bean.intValue}">
- <v:ajaxValidator event="onblur" />
+ <v:beanValidator summary="Invalid number"/>
</h:inputText>
- <rich:message for="intValue" showDetail="true"
showSummary="true" />
+ <rich:message for="intValue" />
</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:outputText></h:outputText>
+ <h:commandButton value="Submit all fields"></h:commandButton>
</h:panelGroup>
</f:facet>
</rich:dataTable>
- </v:graphValidator>
+
</h:form>
- <rich:messages />
+ <rich:messages />
</f:view>
</body>
</html>
Deleted: trunk/samples/seamEAR/ear/src/main/application/META-INF/seamEAR-ds.xml
===================================================================
--- trunk/samples/seamEAR/ear/src/main/application/META-INF/seamEAR-ds.xml 2008-08-04
23:15:16 UTC (rev 9904)
+++ trunk/samples/seamEAR/ear/src/main/application/META-INF/seamEAR-ds.xml 2008-08-04
23:37:51 UTC (rev 9905)
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!DOCTYPE datasources
- PUBLIC "-//JBoss//DTD JBOSS JCA Config 1.5//EN"
- "http://www.jboss.org/j2ee/dtd/jboss-ds_1_5.dtd">
-
-<datasources>
-
- <local-tx-datasource>
- <jndi-name>seamEARDatasource</jndi-name>
- <connection-url>jdbc:hsqldb:.</connection-url>
- <driver-class>org.hsqldb.jdbcDriver</driver-class>
- <user-name>sa</user-name>
- <password></password>
- <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional)
-->
- <metadata>
- <type-mapping>Hypersonic SQL</type-mapping>
- </metadata>
-<!--
- <exception-sorter-class-name>
- org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter
- </exception-sorter-class-name>
- <metadata>
- <type-mapping>mySQL</type-mapping>
- </metadata>
--->
- </local-tx-datasource>
-
-</datasources>
-
Modified: trunk/samples/seamEAR/ejbs/src/main/java/org/richfaces/seam/StatelessBean.java
===================================================================
---
trunk/samples/seamEAR/ejbs/src/main/java/org/richfaces/seam/StatelessBean.java 2008-08-04
23:15:16 UTC (rev 9904)
+++
trunk/samples/seamEAR/ejbs/src/main/java/org/richfaces/seam/StatelessBean.java 2008-08-04
23:37:51 UTC (rev 9905)
@@ -3,15 +3,22 @@
*/
package org.richfaces.seam;
-import javax.ejb.Stateless;
-import org.jboss.seam.annotations.Name;
-
/**
* @author asmirnov
*
*/
public class StatelessBean {
+
+ private String text;
+ public String getText() {
+ return text;
+ }
+
+ public void setText(String text) {
+ this.text = text;
+ }
+
}
Copied: trunk/samples/seamEAR/ejbs/src/main/resources/seamEAR-ds.xml (from rev 9818,
trunk/samples/seamEAR/ear/src/main/application/META-INF/seamEAR-ds.xml)
===================================================================
--- trunk/samples/seamEAR/ejbs/src/main/resources/seamEAR-ds.xml
(rev 0)
+++ trunk/samples/seamEAR/ejbs/src/main/resources/seamEAR-ds.xml 2008-08-04 23:37:51 UTC
(rev 9905)
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!DOCTYPE datasources
+ PUBLIC "-//JBoss//DTD JBOSS JCA Config 1.5//EN"
+ "http://www.jboss.org/j2ee/dtd/jboss-ds_1_5.dtd">
+
+<datasources>
+
+ <local-tx-datasource>
+ <jndi-name>seamEARDatasource</jndi-name>
+ <connection-url>jdbc:hsqldb:.</connection-url>
+ <driver-class>org.hsqldb.jdbcDriver</driver-class>
+ <user-name>sa</user-name>
+ <password></password>
+ <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional)
-->
+ <metadata>
+ <type-mapping>Hypersonic SQL</type-mapping>
+ </metadata>
+<!--
+ <exception-sorter-class-name>
+ org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter
+ </exception-sorter-class-name>
+ <metadata>
+ <type-mapping>mySQL</type-mapping>
+ </metadata>
+-->
+ </local-tx-datasource>
+
+</datasources>
+
Property changes on: trunk/samples/seamEAR/ejbs/src/main/resources/seamEAR-ds.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Date Revision Author
Modified:
trunk/samples/seamEAR/projects/logging/src/main/java/org/richfaces/demo/Log.java
===================================================================
---
trunk/samples/seamEAR/projects/logging/src/main/java/org/richfaces/demo/Log.java 2008-08-04
23:15:16 UTC (rev 9904)
+++
trunk/samples/seamEAR/projects/logging/src/main/java/org/richfaces/demo/Log.java 2008-08-04
23:37:51 UTC (rev 9905)
@@ -1,5 +1,29 @@
package org.richfaces.demo;
+/**
+ * @author asmirnov
+ *
+ */
public class Log {
+ /**
+ * @param message
+ */
+ public void debug(String message) {
+
+ }
+
+ /**
+ * @param message
+ */
+ public void info(String message) {
+
+ }
+
+ /**
+ * @param message
+ */
+ public void error(String message) {
+
+ }
}
Modified: trunk/ui/beanValidator/src/main/config/component/beanValidator.xml
===================================================================
--- trunk/ui/beanValidator/src/main/config/component/beanValidator.xml 2008-08-04 23:15:16
UTC (rev 9904)
+++ trunk/ui/beanValidator/src/main/config/component/beanValidator.xml 2008-08-04 23:37:51
UTC (rev 9905)
@@ -35,6 +35,13 @@
</description>
<defaultvalue><![CDATA["onblur"]]></defaultvalue>
</property>
+ <property exist="true" existintag="true">
+ <name>summary</name>
+ <classname>java.lang.String</classname>
+ <description>
+ Summary message for a validation errors.
+ </description>
+ </property>
<property>
<name>onsubmit</name>
<classname>java.lang.String</classname>
@@ -97,10 +104,19 @@
<description>
<![CDATA[Validate Input by the Bean/Hibernate validator annotations]]>
</description>
- <tag>
+ <tag generate="false">
<name>beanValidator</name>
<classname>org.richfaces.taglib.BeanValidatorTag</classname>
- <superclass>javax.faces.webapp.ValidatorELTag</superclass>
</tag>
+ <taghandler>
+ <classname>org.richfaces.taglib.BeanValidatorHandler</classname>
+ </taghandler>
+ <property exist="true">
+ <name>summary</name>
+ <classname>java.lang.String</classname>
+ <description>
+ Summary message for a validation errors.
+ </description>
+ </property>
</validator>
</components>
Modified:
trunk/ui/beanValidator/src/main/java/org/richfaces/taglib/AjaxValidatorHandler.java
===================================================================
---
trunk/ui/beanValidator/src/main/java/org/richfaces/taglib/AjaxValidatorHandler.java 2008-08-04
23:15:16 UTC (rev 9904)
+++
trunk/ui/beanValidator/src/main/java/org/richfaces/taglib/AjaxValidatorHandler.java 2008-08-04
23:37:51 UTC (rev 9905)
@@ -43,6 +43,7 @@
}
private TagAttribute _event;
+ private TagAttribute _summary;
private AjaxComponentHandler _validatorHandler;
/**
@@ -51,6 +52,7 @@
public AjaxValidatorHandler(ComponentConfig config) {
super(config);
_event = getAttribute("event");
+ _summary = getAttribute("summary");
_validatorHandler = new AjaxComponentHandler(config);
}
@@ -73,6 +75,9 @@
FacesBeanValidator validator = (FacesBeanValidator) facesContext
.getApplication().createValidator(
FacesBeanValidator.BEAN_VALIDATOR_TYPE);
+ if (null != _summary) {
+ validator.setSummary(_summary.getValueExpression(ctx, String.class));
+ }
((EditableValueHolder) parent).addValidator(validator);
}
if (null != this._event) {
Modified:
trunk/ui/beanValidator/src/main/java/org/richfaces/taglib/AjaxValidatorTagBase.java
===================================================================
---
trunk/ui/beanValidator/src/main/java/org/richfaces/taglib/AjaxValidatorTagBase.java 2008-08-04
23:15:16 UTC (rev 9904)
+++
trunk/ui/beanValidator/src/main/java/org/richfaces/taglib/AjaxValidatorTagBase.java 2008-08-04
23:37:51 UTC (rev 9905)
@@ -3,6 +3,7 @@
*/
package org.richfaces.taglib;
+import javax.el.ValueExpression;
import javax.faces.component.EditableValueHolder;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
@@ -16,16 +17,20 @@
/**
* @author asmirnov
- *
+ *
*/
public class AjaxValidatorTagBase extends UIComponentTagBase {
- /**
- * Generate script for given event ( onclick, onenter ... )
- */
- private String event = null;
+ /**
+ * Generate script for given event ( onclick, onenter ... )
+ */
+ private String event = null;
- /* (non-Javadoc)
+ private ValueExpression summary = null;
+
+ /*
+ * (non-Javadoc)
+ *
* @see javax.faces.webapp.UIComponentTagBase#getComponentType()
*/
@Override
@@ -34,54 +39,72 @@
}
/**
- * @param event the event to set
+ * @param event
+ * the event to set
*/
public void setEvent(String event) {
this.event = event;
}
-
+
+ /**
+ * @param summary
+ * the summary to set
+ */
+ public void setSummary(ValueExpression summary) {
+ this.summary = summary;
+ }
+
@Override
public int doStartTag() throws JspException {
- // Locate our parent UIComponentTag
- UIComponentClassicTagBase tag =
- UIComponentClassicTagBase.getParentUIComponentClassicTagBase(pageContext);
- if (tag == null) {
- //PENDING i18n
- throw new JspException("Not nested in a UIComponentTag Error for tag
with handler class:"+
- this.getClass().getName());
- }
+ // Locate our parent UIComponentTag
+ UIComponentClassicTagBase tag = UIComponentClassicTagBase
+ .getParentUIComponentClassicTagBase(pageContext);
+ if (tag == null) {
+ // PENDING i18n
+ throw new JspException(
+ "Not nested in a UIComponentTag Error for tag with handler class:"
+ + this.getClass().getName());
+ }
UIComponent component = tag.getComponentInstance();
- if( !(component instanceof EditableValueHolder)){
- //PENDING i18n
- throw new JspException("Not nested in a UIInput component. Error for
tag with handler class:"+
- this.getClass().getName());
-
+ if (!(component instanceof EditableValueHolder)) {
+ // PENDING i18n
+ throw new JspException(
+ "Not nested in a UIInput component. Error for tag with handler class:"
+ + this.getClass().getName());
+
}
- // Nothing to do unless this tag created a component
- if (tag.getCreated()) {
+ // Nothing to do unless this tag created a component
+ if (tag.getCreated()) {
// New created component, add validator.
FacesContext facesContext = FacesContext.getCurrentInstance();
FacesBeanValidator validator = (FacesBeanValidator) facesContext
.getApplication().createValidator(
FacesBeanValidator.BEAN_VALIDATOR_TYPE);
+ if (null != summary) {
+ validator.setSummary(summary);
+ }
((EditableValueHolder) component).addValidator(validator);
- }
+ }
return super.doStartTag();
}
@Override
protected void setProperties(UIComponent component) {
super.setProperties(component);
- setStringProperty(component, "event", event);
+ setStringProperty(component, "event", event);
}
-
+
@Override
public void release() {
super.release();
event = null;
+ summary = null;
}
- /* (non-Javadoc)
+
+ /*
+ * (non-Javadoc)
+ *
* @see javax.faces.webapp.UIComponentTagBase#getRendererType()
*/
@Override
@@ -91,6 +114,7 @@
@Override
protected String getFacetName() {
- return UIBeanValidator.BEAN_VALIDATOR_FACET + (null == event?"":event);
+ return UIBeanValidator.BEAN_VALIDATOR_FACET
+ + (null == event ? "" : event);
}
}
Added:
trunk/ui/beanValidator/src/main/java/org/richfaces/taglib/BeanValidatorHandler.java
===================================================================
--- trunk/ui/beanValidator/src/main/java/org/richfaces/taglib/BeanValidatorHandler.java
(rev 0)
+++
trunk/ui/beanValidator/src/main/java/org/richfaces/taglib/BeanValidatorHandler.java 2008-08-04
23:37:51 UTC (rev 9905)
@@ -0,0 +1,44 @@
+/**
+ *
+ */
+package org.richfaces.taglib;
+
+import javax.faces.validator.Validator;
+
+import org.richfaces.validator.FacesBeanValidator;
+
+import com.sun.facelets.FaceletContext;
+import com.sun.facelets.tag.TagAttribute;
+import com.sun.facelets.tag.TagConfig;
+import com.sun.facelets.tag.jsf.ValidateHandler;
+import com.sun.facelets.tag.jsf.ValidatorConfig;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class BeanValidatorHandler extends ValidateHandler {
+
+ private TagAttribute _summary;
+
+ /**
+ * @param config
+ */
+ public BeanValidatorHandler(TagConfig config) {
+ super(config);
+ _summary = getAttribute("summary");
+ }
+
+ @Override
+ protected Validator createValidator(FaceletContext ctx) {
+ FacesBeanValidator validator = (FacesBeanValidator) ctx.getFacesContext()
+ .getApplication().createValidator(
+ FacesBeanValidator.BEAN_VALIDATOR_TYPE);
+ if (null != _summary) {
+ validator
+ .setSummary(_summary.getValueExpression(ctx, String.class));
+ }
+ return validator;
+ }
+
+}
Property changes on:
trunk/ui/beanValidator/src/main/java/org/richfaces/taglib/BeanValidatorHandler.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/ui/beanValidator/src/main/java/org/richfaces/taglib/BeanValidatorTag.java
===================================================================
--- trunk/ui/beanValidator/src/main/java/org/richfaces/taglib/BeanValidatorTag.java
(rev 0)
+++
trunk/ui/beanValidator/src/main/java/org/richfaces/taglib/BeanValidatorTag.java 2008-08-04
23:37:51 UTC (rev 9905)
@@ -0,0 +1,57 @@
+/**
+ *
+ */
+package org.richfaces.taglib;
+
+import javax.el.ValueExpression;
+import javax.faces.context.FacesContext;
+import javax.faces.validator.Validator;
+import javax.servlet.jsp.JspException;
+
+import org.richfaces.validator.FacesBeanValidator;
+
+public class BeanValidatorTag extends javax.faces.webapp.ValidatorELTag {
+
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -5230299574915210593L;
+ // Fields
+
+ /*
+ * summary
+ * Summary message for a validation errors.
+ */
+ private ValueExpression _summary;
+ /**
+ * Summary message for a validation errors.
+ * Setter for summary
+ * @param summary - new value
+ */
+ public void setSummary( ValueExpression __summary ){
+ this._summary = __summary;
+ }
+
+
+
+
+ protected Validator createValidator() throws JspException
+ {
+ FacesBeanValidator validator = (FacesBeanValidator)
FacesContext.getCurrentInstance().getApplication().createValidator("org.richfaces.BeanValidator");
+ _setProperties(validator);
+ return validator;
+ }
+
+ // Support method to wire in properties
+ private void _setProperties(FacesBeanValidator validator) throws JspException
+ {
+ if (_summary != null)
+ {
+ if (_summary instanceof ValueExpression)
+ {
+ validator.setSummary(_summary);
+ }
+ }
+ }
+}
Property changes on:
trunk/ui/beanValidator/src/main/java/org/richfaces/taglib/BeanValidatorTag.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/ui/beanValidator/src/main/java/org/richfaces/validator/FacesBeanValidator.java
===================================================================
---
trunk/ui/beanValidator/src/main/java/org/richfaces/validator/FacesBeanValidator.java 2008-08-04
23:15:16 UTC (rev 9904)
+++
trunk/ui/beanValidator/src/main/java/org/richfaces/validator/FacesBeanValidator.java 2008-08-04
23:37:51 UTC (rev 9905)
@@ -3,6 +3,8 @@
*/
package org.richfaces.validator;
+import java.io.Serializable;
+
import javax.el.ELException;
import javax.el.ValueExpression;
import javax.faces.FacesException;
@@ -20,10 +22,44 @@
* @author asmirnov
*
*/
-public class FacesBeanValidator implements Validator {
+public class FacesBeanValidator implements Validator,Serializable {
+ /**
+ *
+ */
+ private static final long serialVersionUID = -264568176252121853L;
public static final String BEAN_VALIDATOR_TYPE =
"org.richfaces.BeanValidator";
+ private ValueExpression summary = null;
+
+ private String summaryString = null;
+ /**
+ * @return the summary
+ */
+ public String getSummary() {
+ String summaryString = null;
+ if(null != summary){
+ summaryString = (String)
summary.getValue(FacesContext.getCurrentInstance().getELContext());
+ }else {
+ summaryString = this.summaryString;
+ }
+ return summaryString;
+ }
+
+ /**
+ * @param summary the summary to set
+ */
+ public void setSummary(ValueExpression summary) {
+ this.summary = summary;
+ }
+
+
+ /**
+ * @param summary the summary to set
+ */
+ public void setSummary(String summary) {
+ this.summaryString = summary;
+ }
/*
* (non-Javadoc)
*
@@ -48,7 +84,7 @@
for (String msg : messages) {
// TODO - create Summary message ?
context.addMessage(component.getClientId(context), new FacesMessage(
- FacesMessage.SEVERITY_ERROR, "", msg));
+ FacesMessage.SEVERITY_ERROR, getSummary(), msg));
}
}
}