beehive-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Richard Feit <richard.f...@bea.com>
Subject Re: checkin request for netui - declarative validation
Date Thu, 30 Sep 2004 18:00:40 GMT
Hi Carlin,

I looked this over and submitted it.  Great catch -- I hadn't known 
about the Validator requirement (virtual requirement) that the field 
exist in the default formset.  We should just revisit this when we 
upgrade to Validator 1.1.

Thanks,
Rich

Carlin Rogers wrote:

> Hi All,
>
> I have another checkin request for Page Flow. The following patch
> file (output from "svn diff") contains another update for the
> declarative validation support.
>
> Fixes:
> - We now create an empty field (place holder) in the default formset
> for all form fields with specific Jpf.ValidationLocaleRules annotation.
> This will ensure that the specific locale field rules will override
> the empty field and be fired at runtime with the commons validator.
> - Minor refactoring to update a method signature that had an argument
> not being used.
>
> DRT/BVT: NetUI (WinXP)
> BB: self (WinXP)
>
> Thanks,
> Carlin
>
>------------------------------------------------------------------------
>
>Index: netui/test/webapps/drt/testRecorder/tests/ValidateField.xml
>===================================================================
>--- netui/test/webapps/drt/testRecorder/tests/ValidateField.xml	(revision 0)
>+++ netui/test/webapps/drt/testRecorder/tests/ValidateField.xml	(revision 0)
>@@ -0,0 +1,663 @@
>+<?xml version="1.0" encoding="UTF-8"?>
>+<ses:recorderSession xmlns:ses="http://beehive.apache.org/netui/tools/testrecorder/2004/session">
>+   <ses:sessionName>ValidateField</ses:sessionName>
>+   <ses:tester>crogers</ses:tester>
>+   <ses:startDate>28 Sep 2004, 05:57:59.786 PM MDT</ses:startDate>
>+   <ses:description>Ensure that a specific locale rule on a field (Jpf.ValidationLocaleRules annotation) fires even if there are no default rules defined for the field.</ses:description>
>+   <ses:tests>
>+      <ses:test>
>+         <ses:testNumber>1</ses:testNumber>
>+         <ses:request>
>+            <ses:protocol>HTTP</ses:protocol>
>+            <ses:protocolVersion>1.1</ses:protocolVersion>
>+            <ses:host>localhost</ses:host>
>+            <ses:port>8080</ses:port>
>+            <ses:uri>/coreWeb/miniTests/validateField/Controller.jpf</ses:uri>
>+            <ses:method>GET</ses:method>
>+            <ses:parameters/>
>+            <ses:cookies>
>+               <ses:cookie>
>+                  <ses:name>JSESSIONID</ses:name>
>+                  <ses:value>10D5EC33240A31F1F9DE0207A1FB82F4</ses:value>
>+               </ses:cookie>
>+            </ses:cookies>
>+            <ses:headers>
>+               <ses:header>
>+                  <ses:name>accept</ses:name>
>+                  <ses:value>image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*</ses:value>
>+               </ses:header>
>+               <ses:header>
>+                  <ses:name>accept-encoding</ses:name>
>+                  <ses:value>gzip, deflate</ses:value>
>+               </ses:header>
>+               <ses:header>
>+                  <ses:name>accept-language</ses:name>
>+                  <ses:value>en-us,fr-ca;q=0.91,fr;q=0.82,en-scouse;q=0.73,fr-FR-MAC;q=0.64,es;q=0.55,en-ca;q=0.45,en-US-MAC;q=0.36,x-pig-latin;q=0.27,sgn-US-MA;q=0.18,i-klingon;q=0.09</ses:value>
>+               </ses:header>
>+               <ses:header>
>+                  <ses:name>connection</ses:name>
>+                  <ses:value>Keep-Alive</ses:value>
>+               </ses:header>
>+               <ses:header>
>+                  <ses:name>cookie</ses:name>
>+                  <ses:value>JSESSIONID=10D5EC33240A31F1F9DE0207A1FB82F4</ses:value>
>+               </ses:header>
>+               <ses:header>
>+                  <ses:name>host</ses:name>
>+                  <ses:value>localhost:8080</ses:value>
>+               </ses:header>
>+               <ses:header>
>+                  <ses:name>user-agent</ses:name>
>+                  <ses:value>Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)</ses:value>
>+               </ses:header>
>+            </ses:headers>
>+         </ses:request>
>+         <ses:response>
>+            <ses:statusCode>200</ses:statusCode>
>+            <ses:reason/>
>+            <ses:responseBody><![CDATA[<!DOCTYPE HTML PUBLIC "//W3C//DTD HTML 4.01 Transitional//EN"
>+	"http://www.w3.org/TR/html4/loose.dtd">
>+<html lang="en">
>+<head>
>+        <base href="http://localhost:8080/coreWeb/miniTests/validateField/index.jsp">
>+    </head>
>+    <body>
>+        <h3>Declarative Validation Test</h3>
>+
>+        <a href="/coreWeb/miniTests/validateField/saveLocale.do">Save current locale</a>
>+        <br/>
>+        <a href="/coreWeb/miniTests/validateField/changeLocale.do">Change to French locale &quot;fr&quot;</a>
>+        <br/>
>+        <a href="/coreWeb/miniTests/validateField/resetLocale.do">Reset locale</a>
>+
>+        <form name="validateForm" action="/coreWeb/miniTests/validateField/validate.do" method="post">
>+            <table>
>+                <tr valign="top">
>+                    <td>item1:</td>
>+                    <td>
>+                    <input type="text" name="{actionForm.item1}">
>+                    </td>
>+                    <td>
>+                    
>+                    </td>
>+                </tr>
>+                <tr valign="top">
>+                    <td>item2:</td>
>+                    <td>
>+                    <input type="text" name="{actionForm.item2}">
>+                    </td>
>+                    <td>
>+                    
>+                    </td>
>+                </tr>
>+            </table>
>+            <br/>
>+            &nbsp;
>+            <input type="submit" name="actionOverride:validate" value="Click">
>+        </form>
>+        <hr>
>+        
>+    </body>
>+</html>]]></ses:responseBody>
>+         </ses:response>
>+      </ses:test>
>+      <ses:test>
>+         <ses:testNumber>2</ses:testNumber>
>+         <ses:request>
>+            <ses:protocol>HTTP</ses:protocol>
>+            <ses:protocolVersion>1.1</ses:protocolVersion>
>+            <ses:host>localhost</ses:host>
>+            <ses:port>8080</ses:port>
>+            <ses:uri>/coreWeb/miniTests/validateField/saveLocale.do</ses:uri>
>+            <ses:method>GET</ses:method>
>+            <ses:parameters/>
>+            <ses:cookies>
>+               <ses:cookie>
>+                  <ses:name>JSESSIONID</ses:name>
>+                  <ses:value>10D5EC33240A31F1F9DE0207A1FB82F4</ses:value>
>+               </ses:cookie>
>+            </ses:cookies>
>+            <ses:headers>
>+               <ses:header>
>+                  <ses:name>accept</ses:name>
>+                  <ses:value>image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*</ses:value>
>+               </ses:header>
>+               <ses:header>
>+                  <ses:name>accept-encoding</ses:name>
>+                  <ses:value>gzip, deflate</ses:value>
>+               </ses:header>
>+               <ses:header>
>+                  <ses:name>accept-language</ses:name>
>+                  <ses:value>en-us,fr-ca;q=0.91,fr;q=0.82,en-scouse;q=0.73,fr-FR-MAC;q=0.64,es;q=0.55,en-ca;q=0.45,en-US-MAC;q=0.36,x-pig-latin;q=0.27,sgn-US-MA;q=0.18,i-klingon;q=0.09</ses:value>
>+               </ses:header>
>+               <ses:header>
>+                  <ses:name>connection</ses:name>
>+                  <ses:value>Keep-Alive</ses:value>
>+               </ses:header>
>+               <ses:header>
>+                  <ses:name>cookie</ses:name>
>+                  <ses:value>JSESSIONID=10D5EC33240A31F1F9DE0207A1FB82F4</ses:value>
>+               </ses:header>
>+               <ses:header>
>+                  <ses:name>host</ses:name>
>+                  <ses:value>localhost:8080</ses:value>
>+               </ses:header>
>+               <ses:header>
>+                  <ses:name>referer</ses:name>
>+                  <ses:value>http://localhost:8080/coreWeb/miniTests/validateField/Controller.jpf</ses:value>
>+               </ses:header>
>+               <ses:header>
>+                  <ses:name>user-agent</ses:name>
>+                  <ses:value>Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)</ses:value>
>+               </ses:header>
>+            </ses:headers>
>+         </ses:request>
>+         <ses:response>
>+            <ses:statusCode>200</ses:statusCode>
>+            <ses:reason/>
>+            <ses:responseBody><![CDATA[<!DOCTYPE HTML PUBLIC "//W3C//DTD HTML 4.01 Transitional//EN"
>+	"http://www.w3.org/TR/html4/loose.dtd">
>+<html lang="en">
>+<head>
>+        <base href="http://localhost:8080/coreWeb/miniTests/validateField/index.jsp">
>+    </head>
>+    <body>
>+        <h3>Declarative Validation Test</h3>
>+
>+        <a href="/coreWeb/miniTests/validateField/saveLocale.do">Save current locale</a>
>+        <br/>
>+        <a href="/coreWeb/miniTests/validateField/changeLocale.do">Change to French locale &quot;fr&quot;</a>
>+        <br/>
>+        <a href="/coreWeb/miniTests/validateField/resetLocale.do">Reset locale</a>
>+
>+        <form name="validateForm" action="/coreWeb/miniTests/validateField/validate.do" method="post">
>+            <table>
>+                <tr valign="top">
>+                    <td>item1:</td>
>+                    <td>
>+                    <input type="text" name="{actionForm.item1}">
>+                    </td>
>+                    <td>
>+                    
>+                    </td>
>+                </tr>
>+                <tr valign="top">
>+                    <td>item2:</td>
>+                    <td>
>+                    <input type="text" name="{actionForm.item2}">
>+                    </td>
>+                    <td>
>+                    
>+                    </td>
>+                </tr>
>+            </table>
>+            <br/>
>+            &nbsp;
>+            <input type="submit" name="actionOverride:validate" value="Click">
>+        </form>
>+        <hr>
>+        
>+    </body>
>+</html>]]></ses:responseBody>
>+         </ses:response>
>+      </ses:test>
>+      <ses:test>
>+         <ses:testNumber>3</ses:testNumber>
>+         <ses:request>
>+            <ses:protocol>HTTP</ses:protocol>
>+            <ses:protocolVersion>1.1</ses:protocolVersion>
>+            <ses:host>localhost</ses:host>
>+            <ses:port>8080</ses:port>
>+            <ses:uri>/coreWeb/miniTests/validateField/validate.do</ses:uri>
>+            <ses:method>POST</ses:method>
>+            <ses:parameters>
>+               <ses:parameter>
>+                  <ses:name>actionOverride:validate</ses:name>
>+                  <ses:value>Click</ses:value>
>+               </ses:parameter>
>+               <ses:parameter>
>+                  <ses:name>{actionForm.item1}</ses:name>
>+                  <ses:value>1</ses:value>
>+               </ses:parameter>
>+               <ses:parameter>
>+                  <ses:name>{actionForm.item2}</ses:name>
>+                  <ses:value>1</ses:value>
>+               </ses:parameter>
>+            </ses:parameters>
>+            <ses:cookies>
>+               <ses:cookie>
>+                  <ses:name>JSESSIONID</ses:name>
>+                  <ses:value>10D5EC33240A31F1F9DE0207A1FB82F4</ses:value>
>+               </ses:cookie>
>+            </ses:cookies>
>+            <ses:headers>
>+               <ses:header>
>+                  <ses:name>accept</ses:name>
>+                  <ses:value>image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*</ses:value>
>+               </ses:header>
>+               <ses:header>
>+                  <ses:name>accept-encoding</ses:name>
>+                  <ses:value>gzip, deflate</ses:value>
>+               </ses:header>
>+               <ses:header>
>+                  <ses:name>accept-language</ses:name>
>+                  <ses:value>en-us,fr-ca;q=0.91,fr;q=0.82,en-scouse;q=0.73,fr-FR-MAC;q=0.64,es;q=0.55,en-ca;q=0.45,en-US-MAC;q=0.36,x-pig-latin;q=0.27,sgn-US-MA;q=0.18,i-klingon;q=0.09</ses:value>
>+               </ses:header>
>+               <ses:header>
>+                  <ses:name>cache-control</ses:name>
>+                  <ses:value>no-cache</ses:value>
>+               </ses:header>
>+               <ses:header>
>+                  <ses:name>connection</ses:name>
>+                  <ses:value>Keep-Alive</ses:value>
>+               </ses:header>
>+               <ses:header>
>+                  <ses:name>content-length</ses:name>
>+                  <ses:value>81</ses:value>
>+               </ses:header>
>+               <ses:header>
>+                  <ses:name>content-type</ses:name>
>+                  <ses:value>application/x-www-form-urlencoded</ses:value>
>+               </ses:header>
>+               <ses:header>
>+                  <ses:name>cookie</ses:name>
>+                  <ses:value>JSESSIONID=10D5EC33240A31F1F9DE0207A1FB82F4</ses:value>
>+               </ses:header>
>+               <ses:header>
>+                  <ses:name>host</ses:name>
>+                  <ses:value>localhost:8080</ses:value>
>+               </ses:header>
>+               <ses:header>
>+                  <ses:name>referer</ses:name>
>+                  <ses:value>http://localhost:8080/coreWeb/miniTests/validateField/saveLocale.do</ses:value>
>+               </ses:header>
>+               <ses:header>
>+                  <ses:name>user-agent</ses:name>
>+                  <ses:value>Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)</ses:value>
>+               </ses:header>
>+            </ses:headers>
>+         </ses:request>
>+         <ses:response>
>+            <ses:statusCode>200</ses:statusCode>
>+            <ses:reason/>
>+            <ses:responseBody><![CDATA[<!DOCTYPE HTML PUBLIC "//W3C//DTD HTML 4.01 Transitional//EN"
>+	"http://www.w3.org/TR/html4/loose.dtd">
>+<html lang="en">
>+<head>
>+        <base href="http://localhost:8080/coreWeb/miniTests/validateField/index.jsp">
>+    </head>
>+    <body>
>+        <h3>Declarative Validation Test</h3>
>+
>+        <a href="/coreWeb/miniTests/validateField/saveLocale.do">Save current locale</a>
>+        <br/>
>+        <a href="/coreWeb/miniTests/validateField/changeLocale.do">Change to French locale &quot;fr&quot;</a>
>+        <br/>
>+        <a href="/coreWeb/miniTests/validateField/resetLocale.do">Reset locale</a>
>+
>+        <form name="validateForm" action="/coreWeb/miniTests/validateField/validate.do" method="post">
>+            <table>
>+                <tr valign="top">
>+                    <td>item1:</td>
>+                    <td>
>+                    <input type="text" name="{actionForm.item1}" value="1">
>+                    </td>
>+                    <td>
>+                    minimum length is 2 characters - All locales
>+
>+                    </td>
>+                </tr>
>+                <tr valign="top">
>+                    <td>item2:</td>
>+                    <td>
>+                    <input type="text" name="{actionForm.item2}" value="1">
>+                    </td>
>+                    <td>
>+                    
>+                    </td>
>+                </tr>
>+            </table>
>+            <br/>
>+            &nbsp;
>+            <input type="submit" name="actionOverride:validate" value="Click">
>+        </form>
>+        <hr>
>+        minimum length is 2 characters - All locales
>+
>+    </body>
>+</html>]]></ses:responseBody>
>+         </ses:response>
>+      </ses:test>
>+      <ses:test>
>+         <ses:testNumber>4</ses:testNumber>
>+         <ses:request>
>+            <ses:protocol>HTTP</ses:protocol>
>+            <ses:protocolVersion>1.1</ses:protocolVersion>
>+            <ses:host>localhost</ses:host>
>+            <ses:port>8080</ses:port>
>+            <ses:uri>/coreWeb/miniTests/validateField/changeLocale.do</ses:uri>
>+            <ses:method>GET</ses:method>
>+            <ses:parameters/>
>+            <ses:cookies>
>+               <ses:cookie>
>+                  <ses:name>JSESSIONID</ses:name>
>+                  <ses:value>10D5EC33240A31F1F9DE0207A1FB82F4</ses:value>
>+               </ses:cookie>
>+            </ses:cookies>
>+            <ses:headers>
>+               <ses:header>
>+                  <ses:name>accept</ses:name>
>+                  <ses:value>image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*</ses:value>
>+               </ses:header>
>+               <ses:header>
>+                  <ses:name>accept-encoding</ses:name>
>+                  <ses:value>gzip, deflate</ses:value>
>+               </ses:header>
>+               <ses:header>
>+                  <ses:name>accept-language</ses:name>
>+                  <ses:value>en-us,fr-ca;q=0.91,fr;q=0.82,en-scouse;q=0.73,fr-FR-MAC;q=0.64,es;q=0.55,en-ca;q=0.45,en-US-MAC;q=0.36,x-pig-latin;q=0.27,sgn-US-MA;q=0.18,i-klingon;q=0.09</ses:value>
>+               </ses:header>
>+               <ses:header>
>+                  <ses:name>connection</ses:name>
>+                  <ses:value>Keep-Alive</ses:value>
>+               </ses:header>
>+               <ses:header>
>+                  <ses:name>cookie</ses:name>
>+                  <ses:value>JSESSIONID=10D5EC33240A31F1F9DE0207A1FB82F4</ses:value>
>+               </ses:header>
>+               <ses:header>
>+                  <ses:name>host</ses:name>
>+                  <ses:value>localhost:8080</ses:value>
>+               </ses:header>
>+               <ses:header>
>+                  <ses:name>referer</ses:name>
>+                  <ses:value>http://localhost:8080/coreWeb/miniTests/validateField/validate.do</ses:value>
>+               </ses:header>
>+               <ses:header>
>+                  <ses:name>user-agent</ses:name>
>+                  <ses:value>Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)</ses:value>
>+               </ses:header>
>+            </ses:headers>
>+         </ses:request>
>+         <ses:response>
>+            <ses:statusCode>200</ses:statusCode>
>+            <ses:reason/>
>+            <ses:responseBody><![CDATA[<!DOCTYPE HTML PUBLIC "//W3C//DTD HTML 4.01 Transitional//EN"
>+	"http://www.w3.org/TR/html4/loose.dtd">
>+<html lang="fr">
>+<head>
>+        <base href="http://localhost:8080/coreWeb/miniTests/validateField/index.jsp">
>+    </head>
>+    <body>
>+        <h3>Declarative Validation Test</h3>
>+
>+        <a href="/coreWeb/miniTests/validateField/saveLocale.do">Save current locale</a>
>+        <br/>
>+        <a href="/coreWeb/miniTests/validateField/changeLocale.do">Change to French locale &quot;fr&quot;</a>
>+        <br/>
>+        <a href="/coreWeb/miniTests/validateField/resetLocale.do">Reset locale</a>
>+
>+        <form name="validateForm" action="/coreWeb/miniTests/validateField/validate.do" method="post">
>+            <table>
>+                <tr valign="top">
>+                    <td>item1:</td>
>+                    <td>
>+                    <input type="text" name="{actionForm.item1}">
>+                    </td>
>+                    <td>
>+                    
>+                    </td>
>+                </tr>
>+                <tr valign="top">
>+                    <td>item2:</td>
>+                    <td>
>+                    <input type="text" name="{actionForm.item2}">
>+                    </td>
>+                    <td>
>+                    
>+                    </td>
>+                </tr>
>+            </table>
>+            <br/>
>+            &nbsp;
>+            <input type="submit" name="actionOverride:validate" value="Click">
>+        </form>
>+        <hr>
>+        
>+    </body>
>+</html>]]></ses:responseBody>
>+         </ses:response>
>+      </ses:test>
>+      <ses:test>
>+         <ses:testNumber>5</ses:testNumber>
>+         <ses:request>
>+            <ses:protocol>HTTP</ses:protocol>
>+            <ses:protocolVersion>1.1</ses:protocolVersion>
>+            <ses:host>localhost</ses:host>
>+            <ses:port>8080</ses:port>
>+            <ses:uri>/coreWeb/miniTests/validateField/validate.do</ses:uri>
>+            <ses:method>POST</ses:method>
>+            <ses:parameters>
>+               <ses:parameter>
>+                  <ses:name>actionOverride:validate</ses:name>
>+                  <ses:value>Click</ses:value>
>+               </ses:parameter>
>+               <ses:parameter>
>+                  <ses:name>{actionForm.item1}</ses:name>
>+                  <ses:value>123</ses:value>
>+               </ses:parameter>
>+               <ses:parameter>
>+                  <ses:name>{actionForm.item2}</ses:name>
>+                  <ses:value>123</ses:value>
>+               </ses:parameter>
>+            </ses:parameters>
>+            <ses:cookies>
>+               <ses:cookie>
>+                  <ses:name>JSESSIONID</ses:name>
>+                  <ses:value>10D5EC33240A31F1F9DE0207A1FB82F4</ses:value>
>+               </ses:cookie>
>+            </ses:cookies>
>+            <ses:headers>
>+               <ses:header>
>+                  <ses:name>accept</ses:name>
>+                  <ses:value>image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*</ses:value>
>+               </ses:header>
>+               <ses:header>
>+                  <ses:name>accept-encoding</ses:name>
>+                  <ses:value>gzip, deflate</ses:value>
>+               </ses:header>
>+               <ses:header>
>+                  <ses:name>accept-language</ses:name>
>+                  <ses:value>en-us,fr-ca;q=0.91,fr;q=0.82,en-scouse;q=0.73,fr-FR-MAC;q=0.64,es;q=0.55,en-ca;q=0.45,en-US-MAC;q=0.36,x-pig-latin;q=0.27,sgn-US-MA;q=0.18,i-klingon;q=0.09</ses:value>
>+               </ses:header>
>+               <ses:header>
>+                  <ses:name>cache-control</ses:name>
>+                  <ses:value>no-cache</ses:value>
>+               </ses:header>
>+               <ses:header>
>+                  <ses:name>connection</ses:name>
>+                  <ses:value>Keep-Alive</ses:value>
>+               </ses:header>
>+               <ses:header>
>+                  <ses:name>content-length</ses:name>
>+                  <ses:value>85</ses:value>
>+               </ses:header>
>+               <ses:header>
>+                  <ses:name>content-type</ses:name>
>+                  <ses:value>application/x-www-form-urlencoded</ses:value>
>+               </ses:header>
>+               <ses:header>
>+                  <ses:name>cookie</ses:name>
>+                  <ses:value>JSESSIONID=10D5EC33240A31F1F9DE0207A1FB82F4</ses:value>
>+               </ses:header>
>+               <ses:header>
>+                  <ses:name>host</ses:name>
>+                  <ses:value>localhost:8080</ses:value>
>+               </ses:header>
>+               <ses:header>
>+                  <ses:name>referer</ses:name>
>+                  <ses:value>http://localhost:8080/coreWeb/miniTests/validateField/changeLocale.do</ses:value>
>+               </ses:header>
>+               <ses:header>
>+                  <ses:name>user-agent</ses:name>
>+                  <ses:value>Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)</ses:value>
>+               </ses:header>
>+            </ses:headers>
>+         </ses:request>
>+         <ses:response>
>+            <ses:statusCode>200</ses:statusCode>
>+            <ses:reason/>
>+            <ses:responseBody><![CDATA[<!DOCTYPE HTML PUBLIC "//W3C//DTD HTML 4.01 Transitional//EN"
>+	"http://www.w3.org/TR/html4/loose.dtd">
>+<html lang="fr">
>+<head>
>+        <base href="http://localhost:8080/coreWeb/miniTests/validateField/index.jsp">
>+    </head>
>+    <body>
>+        <h3>Declarative Validation Test</h3>
>+
>+        <a href="/coreWeb/miniTests/validateField/saveLocale.do">Save current locale</a>
>+        <br/>
>+        <a href="/coreWeb/miniTests/validateField/changeLocale.do">Change to French locale &quot;fr&quot;</a>
>+        <br/>
>+        <a href="/coreWeb/miniTests/validateField/resetLocale.do">Reset locale</a>
>+
>+        <form name="validateForm" action="/coreWeb/miniTests/validateField/validate.do" method="post">
>+            <table>
>+                <tr valign="top">
>+                    <td>item1:</td>
>+                    <td>
>+                    <input type="text" name="{actionForm.item1}" value="123">
>+                    </td>
>+                    <td>
>+                    minimum length is 6 characters - fr locale
>+
>+                    </td>
>+                </tr>
>+                <tr valign="top">
>+                    <td>item2:</td>
>+                    <td>
>+                    <input type="text" name="{actionForm.item2}" value="123">
>+                    </td>
>+                    <td>
>+                    minimum length is 4 characters - fr locale
>+
>+                    </td>
>+                </tr>
>+            </table>
>+            <br/>
>+            &nbsp;
>+            <input type="submit" name="actionOverride:validate" value="Click">
>+        </form>
>+        <hr>
>+        minimum length is 6 characters - fr locale
>+minimum length is 4 characters - fr locale
>+
>+    </body>
>+</html>]]></ses:responseBody>
>+         </ses:response>
>+      </ses:test>
>+      <ses:test>
>+         <ses:testNumber>6</ses:testNumber>
>+         <ses:request>
>+            <ses:protocol>HTTP</ses:protocol>
>+            <ses:protocolVersion>1.1</ses:protocolVersion>
>+            <ses:host>localhost</ses:host>
>+            <ses:port>8080</ses:port>
>+            <ses:uri>/coreWeb/miniTests/validateField/resetLocale.do</ses:uri>
>+            <ses:method>GET</ses:method>
>+            <ses:parameters/>
>+            <ses:cookies>
>+               <ses:cookie>
>+                  <ses:name>JSESSIONID</ses:name>
>+                  <ses:value>10D5EC33240A31F1F9DE0207A1FB82F4</ses:value>
>+               </ses:cookie>
>+            </ses:cookies>
>+            <ses:headers>
>+               <ses:header>
>+                  <ses:name>accept</ses:name>
>+                  <ses:value>image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*</ses:value>
>+               </ses:header>
>+               <ses:header>
>+                  <ses:name>accept-encoding</ses:name>
>+                  <ses:value>gzip, deflate</ses:value>
>+               </ses:header>
>+               <ses:header>
>+                  <ses:name>accept-language</ses:name>
>+                  <ses:value>en-us,fr-ca;q=0.91,fr;q=0.82,en-scouse;q=0.73,fr-FR-MAC;q=0.64,es;q=0.55,en-ca;q=0.45,en-US-MAC;q=0.36,x-pig-latin;q=0.27,sgn-US-MA;q=0.18,i-klingon;q=0.09</ses:value>
>+               </ses:header>
>+               <ses:header>
>+                  <ses:name>connection</ses:name>
>+                  <ses:value>Keep-Alive</ses:value>
>+               </ses:header>
>+               <ses:header>
>+                  <ses:name>cookie</ses:name>
>+                  <ses:value>JSESSIONID=10D5EC33240A31F1F9DE0207A1FB82F4</ses:value>
>+               </ses:header>
>+               <ses:header>
>+                  <ses:name>host</ses:name>
>+                  <ses:value>localhost:8080</ses:value>
>+               </ses:header>
>+               <ses:header>
>+                  <ses:name>referer</ses:name>
>+                  <ses:value>http://localhost:8080/coreWeb/miniTests/validateField/validate.do</ses:value>
>+               </ses:header>
>+               <ses:header>
>+                  <ses:name>user-agent</ses:name>
>+                  <ses:value>Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)</ses:value>
>+               </ses:header>
>+            </ses:headers>
>+         </ses:request>
>+         <ses:response>
>+            <ses:statusCode>200</ses:statusCode>
>+            <ses:reason/>
>+            <ses:responseBody><![CDATA[<!DOCTYPE HTML PUBLIC "//W3C//DTD HTML 4.01 Transitional//EN"
>+	"http://www.w3.org/TR/html4/loose.dtd">
>+<html lang="en">
>+<head>
>+        <base href="http://localhost:8080/coreWeb/miniTests/validateField/index.jsp">
>+    </head>
>+    <body>
>+        <h3>Declarative Validation Test</h3>
>+
>+        <a href="/coreWeb/miniTests/validateField/saveLocale.do">Save current locale</a>
>+        <br/>
>+        <a href="/coreWeb/miniTests/validateField/changeLocale.do">Change to French locale &quot;fr&quot;</a>
>+        <br/>
>+        <a href="/coreWeb/miniTests/validateField/resetLocale.do">Reset locale</a>
>+
>+        <form name="validateForm" action="/coreWeb/miniTests/validateField/validate.do" method="post">
>+            <table>
>+                <tr valign="top">
>+                    <td>item1:</td>
>+                    <td>
>+                    <input type="text" name="{actionForm.item1}">
>+                    </td>
>+                    <td>
>+                    
>+                    </td>
>+                </tr>
>+                <tr valign="top">
>+                    <td>item2:</td>
>+                    <td>
>+                    <input type="text" name="{actionForm.item2}">
>+                    </td>
>+                    <td>
>+                    
>+                    </td>
>+                </tr>
>+            </table>
>+            <br/>
>+            &nbsp;
>+            <input type="submit" name="actionOverride:validate" value="Click">
>+        </form>
>+        <hr>
>+        
>+    </body>
>+</html>]]></ses:responseBody>
>+         </ses:response>
>+      </ses:test>
>+   </ses:tests>
>+   <ses:endDate>28 Sep 2004, 05:58:37.099 PM MDT</ses:endDate>
>+   <ses:testCount>6</ses:testCount>
>+</ses:recorderSession>
>
>Property changes on: netui/test/webapps/drt/testRecorder/tests/ValidateField.xml
>___________________________________________________________________
>Name: svn:eol-style
>   + native
>
>Index: netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml
>===================================================================
>--- netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml	(revision 47488)
>+++ netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml	(working copy)
>@@ -1214,7 +1214,6 @@
>             <category>corePageFlow</category>
>          </categories>
>          <features>
>-            <feature>PageFlow</feature>
>             <feature>Form</feature>
>             <feature>Validation</feature>
>          </features>
>@@ -5174,6 +5173,19 @@
>          </features>
>       </test>
>       <test>
>+         <name>ValidateField</name>
>+         <description>Ensure that a specific locale rule on a field (Jpf.ValidationLocaleRules annotation) fires even if there are no default rules defined for the field.</description>
>+         <webapp>coreWeb</webapp>
>+         <categories>
>+            <category>bvt</category>
>+            <category>corePageFlow</category>
>+         </categories>
>+         <features>
>+            <feature>Form</feature>
>+            <feature>Validation</feature>
>+         </features>
>+      </test>
>+      <test>
>          <name>Validation2</name>
>          <description>Tests of basic validation and validation using the Struts ValidatorPlugIn (as well as netui:error, netui:errors).</description>
>          <webapp>coreWeb</webapp>
>@@ -5209,7 +5221,6 @@
>             <category>corePageFlow</category>
>          </categories>
>          <features>
>-            <feature>PageFlow</feature>
>             <feature>Form</feature>
>             <feature>Validation</feature>
>          </features>
>Index: netui/test/webapps/drt/coreWeb/miniTests/validateField/Controller.jpf
>===================================================================
>--- netui/test/webapps/drt/coreWeb/miniTests/validateField/Controller.jpf	(revision 0)
>+++ netui/test/webapps/drt/coreWeb/miniTests/validateField/Controller.jpf	(revision 0)
>@@ -0,0 +1,177 @@
>+/*
>+ * Copyright 2004 The Apache Software Foundation.
>+ *
>+ * Licensed under the Apache License, Version 2.0 (the "License");
>+ * you may not use this file except in compliance with the License.
>+ * You may obtain a copy of the License at
>+ * 
>+ *     http://www.apache.org/licenses/LICENSE-2.0
>+ * 
>+ * Unless required by applicable law or agreed to in writing, software
>+ * distributed under the License is distributed on an "AS IS" BASIS,
>+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
>+ * See the License for the specific language governing permissions and
>+ * limitations under the License.
>+ *
>+ * $Header:$
>+ */
>+package miniTests.validateField;
>+
>+import java.util.Locale;
>+import javax.servlet.http.HttpServletRequest;
>+import javax.servlet.http.HttpSession;
>+import org.apache.struts.action.ActionMapping;
>+import org.apache.beehive.netui.pageflow.annotations.Jpf;
>+import org.apache.beehive.netui.pageflow.FormData;
>+import org.apache.beehive.netui.pageflow.Forward;
>+import org.apache.beehive.netui.pageflow.PageFlowController;
>+import org.apache.struts.Globals;
>+
>+@Jpf.Controller(
>+    validatableBeans = {
>+        @Jpf.ValidatableBean(
>+            type = miniTests.validateField.Controller.ValidateForm.class,
>+            validatableProperties = {
>+                @Jpf.ValidatableProperty(
>+                    propertyName = "item1",
>+                    validateMinLength = 
>+                        @Jpf.ValidateMinLength(
>+                            chars = 2,
>+                            message = "minimum length is 2 characters - All locales"),
>+                    localeRules = {
>+                        @Jpf.ValidationLocaleRules(
>+                            language = "fr",
>+                            country = "",
>+                            variant = "",
>+                            validateMinLength = 
>+                                @Jpf.ValidateMinLength(
>+                                    chars = 6,
>+                                    message = "minimum length is 6 characters - fr locale"),
>+                            validateMaxLength =
>+                                @Jpf.ValidateMaxLength(
>+                                    chars = 10,
>+                                    message = "maximum length is 10 characters - fr locale")
>+                        )
>+                    }
>+                ),
>+                @Jpf.ValidatableProperty(
>+                    propertyName = "item2",
>+                    localeRules = {
>+                        @Jpf.ValidationLocaleRules(
>+                            language = "fr",
>+                            country = "",
>+                            variant = "",
>+                            validateMinLength =
>+                                @Jpf.ValidateMinLength(
>+                                    chars = 4,
>+                                    message = "minimum length is 4 characters - fr locale")
>+                        )
>+                    }
>+                )
>+            }
>+        )
>+    }
>+)
>+public class Controller extends PageFlowController
>+{
>+    private Locale savedLocale = null;
>+
>+    @Jpf.Action(
>+        forwards={
>+           @Jpf.Forward(name="index", path="index.jsp")
>+        }
>+    )
>+    protected Forward begin()
>+    {
>+        return new Forward("index");
>+    }
>+
>+
>+    /**
>+     * Callback that is invoked when this controller instance is created.
>+     */
>+    protected void onCreate()
>+    {
>+    }
>+
>+    /**
>+     * Callback that is invoked when this controller instance is destroyed.
>+     */
>+    protected void onDestroy(HttpSession session)
>+    {
>+    }
>+
>+
>+    @Jpf.Action(forwards = {
>+        @Jpf.Forward(name = "success",
>+                     path = "index.jsp")
>+    },
>+                validationErrorForward = @Jpf.Forward(name = "errors",
>+                                                      path = "index.jsp"))
>+    protected Forward validate(ValidateForm form)
>+    {
>+        Forward forward = new Forward( "success" );
>+        return forward;
>+    }
>+
>+
>+    public static class ValidateForm extends FormData
>+    {
>+        private String _item1;
>+        private String _item2;
>+
>+        public String getItem1()
>+        { return this._item1; }
>+
>+        public void setItem1(String item)
>+        { this._item1 = item; }
>+
>+        public String getItem2()
>+        { return this._item2; }
>+
>+        public void setItem2(String item)
>+        { this._item2 = item; }
>+    }
>+
>+
>+    @Jpf.Action(forwards = {
>+        @Jpf.Forward(name = "success",
>+                     path = "index.jsp")
>+    })
>+    protected Forward saveLocale()
>+    {
>+        savedLocale = getLocale();
>+        Forward forward = new Forward( "success" );
>+        return forward;
>+    }
>+
>+    @Jpf.Action(forwards = {
>+        @Jpf.Forward(name = "success",
>+                     path = "index.jsp")
>+    })
>+    protected Forward changeLocale()
>+    {
>+        setLocale( new Locale( "fr" ) );
>+        Forward forward = new Forward( "success" );
>+        return forward;
>+    }
>+
>+    @Jpf.Action(forwards = {
>+        @Jpf.Forward(name = "success",
>+                     path = "index.jsp")
>+    })
>+    protected Forward resetLocale()
>+    {
>+        setLocale( savedLocale );
>+        Forward forward = new Forward( "success" );
>+        return forward;
>+    }
>+
>+    public String getLocaleName()
>+    {
>+        Locale l = ( Locale ) getSession().getAttribute( Globals.LOCALE_KEY );
>+        String localeName = ( l == null ) ? "null" : l.toString();
>+        return localeName;
>+    }
>+}
>+
>
>Property changes on: netui/test/webapps/drt/coreWeb/miniTests/validateField/Controller.jpf
>___________________________________________________________________
>Name: svn:eol-style
>   + native
>
>Index: netui/test/webapps/drt/coreWeb/miniTests/validateField/index.jsp
>===================================================================
>--- netui/test/webapps/drt/coreWeb/miniTests/validateField/index.jsp	(revision 0)
>+++ netui/test/webapps/drt/coreWeb/miniTests/validateField/index.jsp	(revision 0)
>@@ -0,0 +1,47 @@
>+<%@ page language="java" contentType="text/html;charset=UTF-8"%>
>+<%@ taglib prefix="netui" uri="http://beehive.apache.org/netui/tags-html-1.0"%>
>+
>+
>+<netui:html>
>+    <head>
>+        <netui:base/>
>+    </head>
>+    <netui:body>
>+        <h3>Declarative Validation Test</h3>
>+
>+        <netui:anchor href="saveLocale.do">Save current locale</netui:anchor>
>+        <br/>
>+        <netui:anchor href="changeLocale.do">Change to French locale &quot;fr&quot;</netui:anchor>
>+        <br/>
>+        <netui:anchor href="resetLocale.do">Reset locale</netui:anchor>
>+
>+        <netui:form action="validate">
>+            <table>
>+                <tr valign="top">
>+                    <td>item1:</td>
>+                    <td>
>+                    <netui:textBox dataSource="actionForm.item1"></netui:textBox>
>+                    </td>
>+                    <td>
>+                    <netui:error value = "item1"/>
>+                    </td>
>+                </tr>
>+                <tr valign="top">
>+                    <td>item2:</td>
>+                    <td>
>+                    <netui:textBox dataSource="actionForm.item2"></netui:textBox>
>+                    </td>
>+                    <td>
>+                    <netui:error value = "item2"/>
>+                    </td>
>+                </tr>
>+            </table>
>+            <br/>
>+            &nbsp;
>+            <netui:button action="validate"></netui:button>
>+        </netui:form>
>+        <hr>
>+        <netui:errors/>
>+    </netui:body>
>+</netui:html>
>+
>
>Property changes on: netui/test/webapps/drt/coreWeb/miniTests/validateField/index.jsp
>___________________________________________________________________
>Name: svn:eol-style
>   + native
>
>Index: netui/src/pageflow/org/apache/beehive/netui/pageflow/FlowController.java
>===================================================================
>--- netui/src/pageflow/org/apache/beehive/netui/pageflow/FlowController.java	(revision 47488)
>+++ netui/src/pageflow/org/apache/beehive/netui/pageflow/FlowController.java	(working copy)
>@@ -35,7 +35,6 @@
> import org.apache.struts.action.ActionForward;
> import org.apache.struts.action.ActionMapping;
> import org.apache.struts.action.ActionServlet;
>-import org.apache.struts.action.Action;
> import org.apache.struts.action.ActionErrors;
> import org.apache.struts.action.ActionMessages;
> import org.apache.struts.config.ActionConfig;
>@@ -464,7 +463,7 @@
>             ActionForward retVal;
>             if ( pfActionMapping != null && pfActionMapping.isSimpleAction() )
>             {
>-                retVal = handleSimpleAction( pfActionMapping, form, request, response, servletContext );
>+                retVal = handleSimpleAction( pfActionMapping, form, request, servletContext );
>             }
>             else
>             {
>@@ -1471,8 +1470,9 @@
>         PageFlowUtils.addValidationError( propertyName, messageKey, getRequest() );
>     }
> 
>-    private static ActionForward handleSimpleAction( PageFlowActionMapping mapping, ActionForm wrappedFormBean,
>-                                                     HttpServletRequest request, HttpServletResponse response,
>+    private static ActionForward handleSimpleAction( PageFlowActionMapping mapping,
>+                                                     ActionForm wrappedFormBean,
>+                                                     HttpServletRequest request,
>                                                      ServletContext servletContext )
>     {
>         
>@@ -1801,7 +1801,7 @@
> 
>         HttpSession session = request.getSession();
>         if (locale == null) {
>-            locale = defaultLocale;
>+            locale = getDefaultLocale();
>         }
>         session.setAttribute(Globals.LOCALE_KEY, locale);
> 
>Index: netui/src/compiler/org/apache/beehive/netui/compiler/model/validation/ValidationModel.java
>===================================================================
>--- netui/src/compiler/org/apache/beehive/netui/compiler/model/validation/ValidationModel.java	(revision 47488)
>+++ netui/src/compiler/org/apache/beehive/netui/compiler/model/validation/ValidationModel.java	(working copy)
>@@ -112,19 +112,38 @@
>                 localeSet = new LocaleSet( locale );
>                 _localeSets.put( locale, localeSet );
>             }
>+
>+            //
>+            // The Commons Validator uses specific locale rules for a field only if there
>+            // is a rule for the same field in the default formset. Therefor,  we need to
>+            // keep a place holder for each locale specific field we find in the default
>+            // formset entity so that the Commons Validator will behave as desired.
>+            //
>+            if ( getField( ruleInfo, _defaultLocaleSet ) == null )
>+            {
>+                //
>+                // create a simple placeholder for the field, without any rules
>+                //
>+                addFieldRule( ruleInfo, ( ValidatorRule ) null, _defaultLocaleSet );
>+            }
>         }
>         
>         addFieldRule( ruleInfo, rule, localeSet );
>     }
>-    
>-    private boolean hasFieldRule( RuleInfo ruleInfo, ValidatorRule rule, LocaleSet localeSet )
>+
>+    private ValidatableField getField( RuleInfo ruleInfo, LocaleSet localeSet )
>     {
>         String entityName = ruleInfo.getEntityName();
>         ValidatableEntity entity = localeSet.getEntity( entityName );
>-        if ( entity == null ) { return false ; }
>+        if ( entity == null ) { return null; }
> 
>         String fieldName = ruleInfo.getFieldName();
>-        ValidatableField field = entity.getField( fieldName );
>+        return entity.getField( fieldName );
>+    }
>+
>+    private boolean hasFieldRule( RuleInfo ruleInfo, ValidatorRule rule, LocaleSet localeSet )
>+    {
>+        ValidatableField field = getField( ruleInfo, localeSet );
>         if ( field == null ) { return false; }
> 
>         return field.hasRule( rule );
>@@ -144,8 +163,11 @@
>                                                            ruleInfo.getFieldDisplayName(),
>                                                            ruleInfo.getFieldDisplayNameKey() ) );
>         }
>-        
>-        field.addRule( rule );
>+
>+        //
>+        // A field element without rules is OK, but we don't want to add a null rule.
>+        //
>+        if ( rule != null ) { field.addRule( rule ); }
>     }
>     
>     public void writeXml( PrintStream outputStream, File mergeFile )
>Index: netui/src/compiler/org/apache/beehive/netui/compiler/model/validation/ValidatableField.java
>===================================================================
>--- netui/src/compiler/org/apache/beehive/netui/compiler/model/validation/ValidatableField.java	(revision 47488)
>+++ netui/src/compiler/org/apache/beehive/netui/compiler/model/validation/ValidatableField.java	(working copy)
>@@ -50,6 +50,8 @@
> 
>     protected boolean hasRule( ValidatorRule rule )
>     {
>+        assert rule != null;
>+
>         String name = rule.getRuleName();
>         for ( int i = 0; i < _rules.size(); i++ )
>         {
>@@ -63,6 +65,8 @@
> 
>     public void addRule( ValidatorRule rule )
>     {
>+        assert rule != null;
>+
>         _rules.add( rule );
>     }
>     
>@@ -88,7 +92,11 @@
>     {
>         assert fieldElement.getProperty().equals( _propertyName );
>         
>-        if ( fieldElement.getDepends() == null ) fieldElement.setDepends( getDependsList() );
>+        if ( fieldElement.getDepends() == null ) {
>+            String depends = getDependsList();
>+
>+            if ( depends != null && depends.length() > 0 ) { fieldElement.setDepends( depends ); }
>+        }
>         
>         //
>         // Add the display name as the default first argument (can be overridden by individual rules).
>@@ -124,11 +132,18 @@
>             }
>         }
>         
>-        if ( defaultArg0Element == null ) defaultArg0Element = fieldElement.addNewArg0();
>-        defaultArg0Element.setKey( displayName );
>-        defaultArg0Element.setResource( Boolean.toString( displayNameIsResource ) );
>-        
>-        
>+        if ( defaultArg0Element == null && _rules.size() > 0 )
>+        {
>+            defaultArg0Element = fieldElement.addNewArg0();
>+        }
>+
>+        if ( defaultArg0Element != null ) 
>+        {
>+            defaultArg0Element.setKey( displayName );
>+            defaultArg0Element.setResource( Boolean.toString( displayNameIsResource ) );
>+        }
>+
>+
>         //
>         // Go through the rules, and add each one.  Each rule can spray into 1) an entry in the comma-separated
>         // rules dependencies list, 2) a set of <var> elements, 3) a set of <argN> elements.
>  
>

Mime
View raw message