You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Matthieu MARC <ma...@angers.ensam.fr> on 2008/05/28 07:31:44 UTC
Multiple fields validation
Hi,
I have a question about field validation.
I made a form using struts2 tags in which I use an iterator to make
select control :
<s:iterator value="week.semaine">
<s:label labelposition="top" label="%{displayName}" />
<s:select name="week.semaine[%{index}].am"
onchange="countHour();" id="am%{index}" label="matin" list="heures"
value="%{am}" />
<s:select name="week.semaine[%{index}].pm"
onchange="countHour();" id="pm%{index}" label="après-midi" list="heures"
value="%{pm}" />
</s:iterator>
The list "heures" is a treeMap like 0 -> 00:00, 15 -> 00:15, 30 -> 00:30 ...
All is ok. Now, I want to validate the fields to secure the application.
And I do not want to make 14 validators which are identical.
Is it possible to use regex for a 'name' in 'field', like :
validators>
<field name="week.semaine*.[a|p]m">
...
</field>
</validators>
Thanks for help.
Cordialy,
--
Matthieu MARC
matthieu.marc@angers.ensam.fr
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Multiple fields validation
Posted by sagarlotiya <sa...@aspl.in>.
hi
It is not necessary to user validation.xml file in all circumstances, for
this kind of dynamically generated fields, you should put validation in
Java file.
I mean in your action class.
Make one function like validatFilelds and make sure that if all the things
are valid then only allow action to proceed further.
Matthieu MARC wrote:
>
> Hi,
>
> I have a question about field validation.
>
> I made a form using struts2 tags in which I use an iterator to make
> select control :
>
> <s:iterator value="week.semaine">
> <s:label labelposition="top" label="%{displayName}" />
> <s:select name="week.semaine[%{index}].am"
> onchange="countHour();" id="am%{index}" label="matin" list="heures"
> value="%{am}" />
> <s:select name="week.semaine[%{index}].pm"
> onchange="countHour();" id="pm%{index}" label="après-midi" list="heures"
> value="%{pm}" />
> </s:iterator>
>
> The list "heures" is a treeMap like 0 -> 00:00, 15 -> 00:15, 30 -> 00:30
> ...
>
> All is ok. Now, I want to validate the fields to secure the application.
> And I do not want to make 14 validators which are identical.
>
> Is it possible to use regex for a 'name' in 'field', like :
>
> validators>
> <field name="week.semaine*.[a|p]m">
> ...
> </field>
> </validators>
>
> Thanks for help.
>
> Cordialy,
>
>
> --
> Matthieu MARC
> matthieu.marc@angers.ensam.fr
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/Multiple-fields-validation-tp17505509p17506267.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org