You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Hodgins, Grant" <Gr...@SierraSystems.com> on 2008/02/08 02:24:10 UTC

Dynamic indexed field name in validation?

I have a dynamic multi line collection of dates with a date converter doing its job perfectly - populating dates or reporting conversion errors by field as it should.

What I'm wondering is if it's possible to dynamically reference these fields without providing individually fixed definitions for each possible field.

For example, I can define each named field as follows:
<field name="account.userRoles[0].startDate">
  <field-validator type="conversion">
    <param name="repopulateField">true</param>
    <message>${getText("errors.invalid.date")}</message>
  </field-validator>
</field>

<field name="account.userRoles[1].startDate">
  <field-validator type="conversion">
    <param name="repopulateField">true</param>
    <message>${getText("errors.invalid.date")}</message>
  </field-validator>
</field>

etc.

This approach does work. However, I'd prefer have a single definition perhaps using a wildcard/regex since I don't know how many fields the user will submit.

Is it possible to substitute some kind of wildcard or regex here?

Thanks,
Grant




----Notice Regarding Confidentiality----
This email, including any and all attachments, (this "Email") is intended only for the party to whom it is addressed and may contain information that is confidential or privileged.  Sierra Systems Group Inc. and its affiliates accept no responsibility for any loss or damage suffered by any person resulting from any unauthorized use of or reliance upon this Email.  If you are not the intended recipient, you are hereby notified that any dissemination, copying or other use of this Email is prohibited.  Please notify us of the error in communication by return email and destroy all copies of this Email.  Thank you.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Dynamic indexed field name in validation?

Posted by Gabriel Belingueres <be...@gmail.com>.
I had got the same problem some time ago. I couldn't specify an
expression for the validator to iterate for each element of the
collection. I finally opted for writing a validation method in the
action class.

2008/2/10, j alex <st...@gmail.com>:
> I used a custom validator to loop thru each element , validate it and add
> errors if present . The # of elements could vary per user, and was not known
> upfront. Really want to know if this can be achieved via validation xml
>
> On Feb 7, 2008 8:24 PM, Hodgins, Grant <Gr...@sierrasystems.com>
> wrote:
>
> > I have a dynamic multi line collection of dates with a date converter
> > doing its job perfectly - populating dates or reporting conversion errors by
> > field as it should.
> >
> > What I'm wondering is if it's possible to dynamically reference these
> > fields without providing individually fixed definitions for each possible
> > field.
> >
> > For example, I can define each named field as follows:
> > <field name="account.userRoles[0].startDate">
> >  <field-validator type="conversion">
> >    <param name="repopulateField">true</param>
> >    <message>${getText("errors.invalid.date")}</message>
> >  </field-validator>
> > </field>
> >
> > <field name="account.userRoles[1].startDate">
> >  <field-validator type="conversion">
> >    <param name="repopulateField">true</param>
> >    <message>${getText("errors.invalid.date")}</message>
> >  </field-validator>
> > </field>
> >
> > etc.
> >
> > This approach does work. However, I'd prefer have a single definition
> > perhaps using a wildcard/regex since I don't know how many fields the user
> > will submit.
> >
> > Is it possible to substitute some kind of wildcard or regex here?
> >
> > Thanks,
> > Grant
> >
> >
> >
> >
> > ----Notice Regarding Confidentiality----
> > This email, including any and all attachments, (this "Email") is intended
> > only for the party to whom it is addressed and may contain information that
> > is confidential or privileged.  Sierra Systems Group Inc. and its affiliates
> > accept no responsibility for any loss or damage suffered by any person
> > resulting from any unauthorized use of or reliance upon this Email.  If you
> > are not the intended recipient, you are hereby notified that any
> > dissemination, copying or other use of this Email is prohibited.  Please
> > notify us of the error in communication by return email and destroy all
> > copies of this Email.  Thank you.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Dynamic indexed field name in validation?

Posted by j alex <st...@gmail.com>.
I used a custom validator to loop thru each element , validate it and add
errors if present . The # of elements could vary per user, and was not known
upfront. Really want to know if this can be achieved via validation xml

On Feb 7, 2008 8:24 PM, Hodgins, Grant <Gr...@sierrasystems.com>
wrote:

> I have a dynamic multi line collection of dates with a date converter
> doing its job perfectly - populating dates or reporting conversion errors by
> field as it should.
>
> What I'm wondering is if it's possible to dynamically reference these
> fields without providing individually fixed definitions for each possible
> field.
>
> For example, I can define each named field as follows:
> <field name="account.userRoles[0].startDate">
>  <field-validator type="conversion">
>    <param name="repopulateField">true</param>
>    <message>${getText("errors.invalid.date")}</message>
>  </field-validator>
> </field>
>
> <field name="account.userRoles[1].startDate">
>  <field-validator type="conversion">
>    <param name="repopulateField">true</param>
>    <message>${getText("errors.invalid.date")}</message>
>  </field-validator>
> </field>
>
> etc.
>
> This approach does work. However, I'd prefer have a single definition
> perhaps using a wildcard/regex since I don't know how many fields the user
> will submit.
>
> Is it possible to substitute some kind of wildcard or regex here?
>
> Thanks,
> Grant
>
>
>
>
> ----Notice Regarding Confidentiality----
> This email, including any and all attachments, (this "Email") is intended
> only for the party to whom it is addressed and may contain information that
> is confidential or privileged.  Sierra Systems Group Inc. and its affiliates
> accept no responsibility for any loss or damage suffered by any person
> resulting from any unauthorized use of or reliance upon this Email.  If you
> are not the intended recipient, you are hereby notified that any
> dissemination, copying or other use of this Email is prohibited.  Please
> notify us of the error in communication by return email and destroy all
> copies of this Email.  Thank you.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>