Author: alexsmirnov
Date: 2011-03-17 14:53:34 -0400 (Thu, 17 Mar 2011)
New Revision: 22255
Added:
branches/4.0.X/examples/validator-demo/src/main/webapp/examples/clientAndajaxValidator.xhtml
Modified:
branches/4.0.X/examples/validator-demo/src/main/java/org/richfaces/example/Bean.java
branches/4.0.X/examples/validator-demo/src/main/webapp/examples/faces-validators.xhtml
branches/4.0.X/ui/validator/
branches/4.0.X/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientAndAjaxScript.java
branches/4.0.X/ui/validator/ui/src/main/resources/META-INF/resources/org.richfaces/message.js
branches/4.0.X/ui/validator/ui/src/main/resources/META-INF/resources/org.richfaces/richfaces-csv.js
Log:
CODING IN PROGRESS - issue RF-10769: CSV: JavaScript error in mixed client/ajax
validation.
https://issues.jboss.org/browse/RF-10769
Modified:
branches/4.0.X/examples/validator-demo/src/main/java/org/richfaces/example/Bean.java
===================================================================
---
branches/4.0.X/examples/validator-demo/src/main/java/org/richfaces/example/Bean.java 2011-03-17
18:47:39 UTC (rev 22254)
+++
branches/4.0.X/examples/validator-demo/src/main/java/org/richfaces/example/Bean.java 2011-03-17
18:53:34 UTC (rev 22255)
@@ -1,5 +1,11 @@
package org.richfaces.example;
+import javax.validation.constraints.Digits;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Pattern;
+
+import org.hibernate.validator.constraints.NotEmpty;
+
public class Bean {
public static final String FOO_VALUE = "fooValue";
@@ -16,6 +22,8 @@
private String email;
+ private String numbers;
+
/**
* @return the value
*/
@@ -98,5 +106,18 @@
public void setEmail(String email) {
this.email = email;
}
+ @NotNull
+ @NotEmpty
+ @Digits(fraction = 0, integer = 2)
+ @Pattern(regexp = "^[0-9-]+$", message = "must contain only
numbers")
+ public String getNumbers()
+ {
+ return this.numbers;
+ }
+
+ public void setNumbers(String numbers) {
+ this.numbers = numbers;
+ }
+
}
Added:
branches/4.0.X/examples/validator-demo/src/main/webapp/examples/clientAndajaxValidator.xhtml
===================================================================
---
branches/4.0.X/examples/validator-demo/src/main/webapp/examples/clientAndajaxValidator.xhtml
(rev 0)
+++
branches/4.0.X/examples/validator-demo/src/main/webapp/examples/clientAndajaxValidator.xhtml 2011-03-17
18:53:34 UTC (rev 22255)
@@ -0,0 +1,39 @@
+<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:csv="http://richfaces.org/csv"
+
xmlns:a4j="http://richfaces.org/a4j"
+
xmlns:c="http://java.sun.com/jsp/jstl/core">
+<ui:composition template="/layout/template.xhtml">
+ <ui:param name="title" value="JSF validator by client and AJAX"
/>
+ <!-- Page header -->
+ <ui:define name="header">
+ <h1>Client validation with AJAX callback</h1>
+ </ui:define>
+ <!-- content -->
+ <ui:define name="content">
+ <h:form id="form">
+ <h:panelGrid columns="4">
+ <h:outputLabel for="text" value="Pattern ^ab[1-3]*$ and length
0-3"/>
+ <h:inputText id="text" value="#{test.value}">
+ <f:validateRegex pattern="^ab[1-3]*$"/>
+ <f:validator validatorId="custom" />
+ <csv:validator event="blur" />
+ </h:inputText>
+ <h:outputText id="out"
value="#{test.value}"></h:outputText>
+ <csv:message id="uiMessage" for="text" />
+ <h:outputLabel for="number" value="Four annotations for
number"/>
+ <h:inputText id="number" value="#{test.numbers}">
+ <csv:validator />
+ </h:inputText>
+ <h:outputText id="outNum"
value="#{test.numbers}"></h:outputText>
+ <csv:message id="uiNumMessage" for="number" />
+ </h:panelGrid>
+ <h:commandButton value="Submit form"/>
+ <a4j:commandButton value="AJAX Submit"
render="out"/>
+ </h:form>
+ <csv:messages />
+ </ui:define>
+</ui:composition>
+</html>
Property changes on:
branches/4.0.X/examples/validator-demo/src/main/webapp/examples/clientAndajaxValidator.xhtml
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
branches/4.0.X/examples/validator-demo/src/main/webapp/examples/faces-validators.xhtml
===================================================================
---
branches/4.0.X/examples/validator-demo/src/main/webapp/examples/faces-validators.xhtml 2011-03-17
18:47:39 UTC (rev 22254)
+++
branches/4.0.X/examples/validator-demo/src/main/webapp/examples/faces-validators.xhtml 2011-03-17
18:53:34 UTC (rev 22255)
@@ -2,6 +2,7 @@
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="http://richfaces.org/a4j"
xmlns:csv="http://richfaces.org/csv"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<ui:composition template="/layout/template.xhtml">
Property changes on: branches/4.0.X/ui/validator
___________________________________________________________________
Added: svn:mergeinfo
+ /trunk/ui/validator:22079
Modified:
branches/4.0.X/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientAndAjaxScript.java
===================================================================
---
branches/4.0.X/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientAndAjaxScript.java 2011-03-17
18:47:39 UTC (rev 22254)
+++
branches/4.0.X/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientAndAjaxScript.java 2011-03-17
18:53:34 UTC (rev 22255)
@@ -35,6 +35,7 @@
@Override
protected void appendAjaxParameter(Appendable target) throws IOException {
+ target.append(',');
appendAjaxParameter(target, ajaxScript);
}
/* (non-Javadoc)
Modified:
branches/4.0.X/ui/validator/ui/src/main/resources/META-INF/resources/org.richfaces/message.js
===================================================================
---
branches/4.0.X/ui/validator/ui/src/main/resources/META-INF/resources/org.richfaces/message.js 2011-03-17
18:47:39 UTC (rev 22254)
+++
branches/4.0.X/ui/validator/ui/src/main/resources/META-INF/resources/org.richfaces/message.js 2011-03-17
18:53:34 UTC (rev 22255)
@@ -37,7 +37,10 @@
if (!this.options.forComponentId) {
if (!message) {
// rf.csv.clearMessage
- $(rf.getDomElement(this.id+':'+sourceId)).remove();
+ var element;
+ while(element=rf.getDomElement(this.id+':'+sourceId)){
+ $(element).remove();
+ }
} else {
renderMessage.call(this,sourceId,message);
}
Modified:
branches/4.0.X/ui/validator/ui/src/main/resources/META-INF/resources/org.richfaces/richfaces-csv.js
===================================================================
---
branches/4.0.X/ui/validator/ui/src/main/resources/META-INF/resources/org.richfaces/richfaces-csv.js 2011-03-17
18:47:39 UTC (rev 22254)
+++
branches/4.0.X/ui/validator/ui/src/main/resources/META-INF/resources/org.richfaces/richfaces-csv.js 2011-03-17
18:53:34 UTC (rev 22255)
@@ -185,7 +185,7 @@
}
}
}
- if(!result && !params.da && params.a){
+ if(result && !params.da && params.a){
params.a.call(element,event,id);
}
return result;
@@ -197,18 +197,24 @@
*
*/
var _convertNatural = function(value,label,msg,min,max,sample){
- var result; value = $.trim(value);
- if (!rf.csv.RE_DIGITS.test(value) || (result=parseInt(value,10))<min ||
result>max) {
+ var result = null;
+ if(value){
+ value = $.trim(value);
+ if (!rf.csv.RE_DIGITS.test(value) || (result=parseInt(value,10))<min ||
result>max) {
throw rf.csv.interpolateMessage(msg, sample?[value, sample, label]:[value,label]);
+ }
}
return result;
}
var _convertReal = function(value,label,msg,sample){
- var result; value = $.trim(value);
- if (!rf.csv.RE_FLOAT.test(value) || isNaN(result=parseFloat(value)) ) {
+ var result = null;
+ if(value){
+ value = $.trim(value);
+ if (!rf.csv.RE_FLOAT.test(value) || isNaN(result=parseFloat(value)) ) {
// TODO - check Float limits.
throw rf.csv.interpolateMessage(msg, sample?[value, sample, label]:[value,label]);
+ }
}
return result;
}
@@ -341,7 +347,7 @@
validateRegex(value,label,params.regexp,msg);
},
"validateRequired": function (value,label,params,msg) {
- if (!value ) {
+ if (undefined === value || null===value || "" === value ) {
throw rf.csv.interpolateMessage(msg, [label]);
}
},