You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Paul Benedict (JIRA)" <ji...@apache.org> on 2007/08/27 05:04:34 UTC

[jira] Updated: (STR-1766) [validator] Nice to have: current index in validwhen rule

     [ https://issues.apache.org/struts/browse/STR-1766?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul Benedict updated STR-1766:
-------------------------------

    Affects Version/s:     (was: Future)
                       1.4.0
             Assignee:     (was: Struts Developers)

> [validator] Nice to have: current index in validwhen rule
> ---------------------------------------------------------
>
>                 Key: STR-1766
>                 URL: https://issues.apache.org/struts/browse/STR-1766
>             Project: Struts 1
>          Issue Type: Improvement
>          Components: Core
>    Affects Versions: 1.4.0
>         Environment: Operating System: All
> Platform: All
>            Reporter: Jim Prantzalos
>            Priority: Minor
>
> 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

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.