You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Peter L. Berghold" <pe...@berghold.net> on 2007/04/04 04:05:12 UTC
Conditional validation in Struts.
Consider the following sniglet from my validation.xml:
<field property="nonmember_dropin_rate_rq" depends="requiredif">
<arg0 key="label.nonmember_dropin_rate"/>
<var>
<var-name>field[0]</var-name>
<var-value>dropins_allowed_rq</var-value>
</var>
<var>
<var-name>fieldTest[0]</var-name>
<var-value>EQUALS</var-value>
</var>
<var>
<var-name>fieldValue[0]</var-name>
<var-value>on</var-value>
</var>
</field>
What I'm trying to accomplish is if the checkbox dropins_allowed_rq is
checked then I want to consider the text field nonmember_dropin_rate_rq
as a required field, otherwise ignore it.
I've tried a few different variants and none have worked. Pointers
anybody?
(all my other validation works)
--
Peter L. Berghold Unix Professional
Peter@Berghold.Net AIM: redcowdawg YIM: blue_cowdawg
"Those who fail to learn from history are condemned to repeat it."
Re: Conditional validation in Struts.
Posted by Dave Newton <ne...@yahoo.com>.
--- "Peter L. Berghold" <pe...@berghold.net> wrote:
> Consider the following sniglet from my
> validation.xml:
>
> <field property="nonmember_dropin_rate_rq"
> depends="requiredif">
> <arg0 key="label.nonmember_dropin_rate"/>
> <var>
> <var-name>field[0]</var-name>
> <var-value>dropins_allowed_rq</var-value>
> </var>
> <var>
> <var-name>fieldTest[0]</var-name>
> <var-value>EQUALS</var-value>
> </var>
> <var>
> <var-name>fieldValue[0]</var-name>
> <var-value>on</var-value>
> </var>
> </field>
What version of Struts are you using? IIRC requiredif
was deprecated immediately after 1.1 (I just checked;
see doc link below) in favor of validwhen.
That said, if "on" is the value of the checked box
(and, perhaps, it's a java.lang.String) I would have
thought what you had there was correct :/
http://struts.apache.org/1.1/userGuide/dev_validator.html
BTW, links to version 1.1 seem to be somewhat hosed; I
had to play around a bit to get there.
d.
____________________________________________________________________________________
Don't get soaked. Take a quick peek at the forecast
with the Yahoo! Search weather shortcut.
http://tools.search.yahoo.com/shortcuts/#loc_weather
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org