You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Brian Relph <re...@gmail.com> on 2007/11/20 17:49:46 UTC
validation errors
Can I reference action errors / messages in a similar way to field errors?
I have a custom validator for a date field that is split into month/day/year
fields, but i want the errors for it to appear next to inputs. Here are my
validators:
<field name="ssn">
<field-validator type="requiredstring">
<message key="validator.required" />
</field-validator>
<field-validator type="regex">
<param name="expression">^\d{4}$</param>
<message key="validator.format" />
</field-validator>
</field>
<validator type="splitdatevalidator">
<message key="validator.date.format" />
</validator>
which i reference in my jsp like so:
<s:fielderror theme="healthe">
<s:param>ssn</s:param>
</s:fielderror>
how would i reference the "splitdatevalidator" in my jsp?
Re: validation errors
Posted by Brian Relph <re...@gmail.com>.
I realized that since this was a custom validator, I can add the error
message to the fieldErrors with whatever key i choose - so i can now
reference that error message. What about for other validators, like the
expression validator, is there a way to specify a key for it? I think the
expression validator by default adds to the actionErrors, is there another
way besides re-writing it and specifying to add to the fieldErrors instead?
On 11/20/07, Brian Relph <re...@gmail.com> wrote:
>
>
> Can I reference action errors / messages in a similar way to field
> errors? I have a custom validator for a date field that is split into
> month/day/year fields, but i want the errors for it to appear next to
> inputs. Here are my validators:
>
> <field name="ssn">
> <field-validator type="requiredstring">
> <message key="validator.required" />
> </field-validator>
> <field-validator type="regex">
> <param name="expression">^\d{4}$</param>
> <message key="validator.format" />
> </field-validator>
> </field>
>
> <validator type="splitdatevalidator">
> <message key="validator.date.format" />
> </validator>
>
> which i reference in my jsp like so:
>
> <s:fielderror theme="healthe">
> <s:param>ssn</s:param>
> </s:fielderror>
>
> how would i reference the "splitdatevalidator" in my jsp?
>