DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUGĀ·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=39121>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED ANDĀ·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=39121





------- Additional Comments From [EMAIL PROTECTED]  2006-04-19 02:14 -------
(In reply to comment #4)
> Reopening for documentation review.  Are these pages up to date with the 
changes?
>  http://struts.apache.org/struts-shale/features-commons-validator.html
>  http://wiki.apache.org/struts/Shale/Validation

I believe that they do describe the current validator.  The areas expanded on 
were not specifically addressed in the documentation  anyway.  The area that 
was fuzzy before was defining a new validation rule.  There was not any direct 
association of a method parameter with a variable.  The logic just happed to 
assemble the parameters in a predefined order based on the know set of rules.  
This was also true for substitution of message parameters associated with 
variables.  

However, we might want to expand on how you can create a custom rule.  The 
CommonsVaidatorTestCase shows and example.  

JSP:
<s:commonsValidator type="testRule2" message="{0} must be one of the 
following: {2}." arg="Favorite Color">
    <s:validatorVar name="enumerations" value="black, yellow, red"/>
</s:commonsValidator>


validation.xml
<global>

  <validator name="testRule2"
             classname="org.apache.shale.validator.CommonsValidatorTestCase"
             method="isValid"
             methodParams="java.lang.String, java.lang.String"
             msg="errors.invalid">
  </validator>


</global>

<formset>
      <form name="org.apache.shale.validator.testRule2">
          <field property="testRule2">
              <arg position="0" name="message" key="arg" resource="false"/>
              <arg position="1" name="message" key="submittedValue" 
resource="false"/>
              <arg position="2" name="message" key="enumerations" 
resource="false"/>
              
              <arg position="0" name="parameter" key="submittedValue" 
resource="false"/> 
              <arg position="1" name="parameter" key="enumerations" 
resource="false"/>           
          </field>      
      </form>  
               
</formset>


Rule Method:
//test validation rule
public static boolean isValid(String value, String colors) {
       StringTokenizer tokenizer = new StringTokenizer(colors, ",");
       
       while (tokenizer.hasMoreTokens()) {
          String color = tokenizer.nextToken().trim();
          if (value.equals(color))
             return true;
       }
    
       return false;
}


Do you thing that something like this would be a good addition?

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to