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

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=23351

Nice to have: current index in validwhen rule

           Summary: Nice to have: current index in validwhen rule
           Product: Struts
           Version: Nightly Build
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Enhancement
          Priority: Other
         Component: Validator Framework
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


The 'validwhen' rule defines the literal *this*, which contains the
value of the field currently being tested.

It would be nice to have something like *this*.index or [].count, which
contains the index of the property being tested.

That way, I could, for example, create a rule that applies to every
other indexed property:

<var-value>((*this*.index % 2 == '0') and (*this* != null))</var-value>

.. or, I could create a more meaniningful validation message, such as:

"Employment #2: must specify a start date for primary employer 'Motown Music'."

.. using something like:

<field property="startDate" indexedListProperty="emps" depends="validwhen">
  <msg name="validwhen" key="errors.startdate.required" />
  <arg0 property="*this*.index"/>
  <arg1 property="emps[].employerName"/>
  <var>
    <var-name>test</var-name>
    <var-value>(((*this*.index == '0') and (*this* != null)) or (*this*.index 
== '0'))</var-value>
  </var>
</field>

There is actually another enhancement disguised in the above. Currently,
arg0-arg3 only accept the attribute 'key'. I suggest adding another
attribute called 'property' (for example) that allows me to pass values
of indexed properties as message params. You should be allowed to use
this or a similar attribute to pass the index value (*this*.index) too.


While I'm at it, here's another suggestion too -- how about an 'invalidwhen'
rule. So that I don't have to have ugly rules like the above:

<var-value>(((*this*.index == '0') and (*this* != null)) or (*this*.index !
= '0'))</var-value>

.. If I had a 'invalidwhen' rule, I could use the following instead:

((*this*.index == '0') and (*this* == null))


Just a few suggestions. Let me know what you think.


-jim

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

Reply via email to