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 McSweeney <br...@aurium.net> on 2003/06/26 14:43:32 UTC
requiredif - simple example
Hi all,
The validator package works well for me.
But I'm trying to use the requiredif and failing.
I know there has been previous discussion of this,
but I'm trying to a simple validation based on a checkbox
so perhaps someone could tell me where I'm going wrong.
For example,
I want to validate a creditcard, if a checkbox is checked.
I currently am trying to do this as follows:
<form name="myForm">
<field property="creditCard"
depends="requiredif,creditCard">
<arg0 key="myForm.creditCard"/>
<arg0
name="creditCard"
key="CreditCard"
resource="false"
/>
<arg0
name="requiredif"
key="A Credit-Card is"
resource="false"
/>
<var>
<var-name>myForm.checked</var-name>
<var-value>on</var-value>
</var>
</field>
</form>
The form name is: myForm
The creditcard field is named "creditCard"
The checkbox field is named "checked"
Note that all other types of validation are working correctly for me.
Any help would be SO much appreciated.
Brian
RE: requiredif - simple example
Posted by Brian McSweeney <br...@aurium.net>.
Hi Kevin,
Thanks for the reply.
I'm a little confused by your example though.
First off - what does the ${4dig} mean?
This won't validate a checkbox, right?
Second, you have a lot of stuff commented out.
Are these fields getting validated?
Finally, if I wanted to just test against a boolean
being checked would I do something like the following?
<field property="prop1" depends="mask">
<msg name="requiredif" key="app224Form.aForm.prop1.req"/>
<msg name="mask" key="app224Form.aForm.prop1.mask"/>
<var>
<var-name>mask</var-name>
<var-value>${4dig}</var-value>
</var>
<var>
<var-name>field-checked[0]</var-name>
<var-value>true</var-value>
</var>
I'm quite confused! Sorry,
Thanks,
Brian
-----Original Message-----
From: Kevin Robair [mailto:krobair@yahoo.com]
Sent: 26 June 2003 14:30
To: Struts Users Mailing List
Subject: Re: requiredif - simple example
The following worked for me. Note that in RC1, the <var-name> tag values
are expected to be field-test[n], not fieldTest[n] and so on....
The requiredif check was removed because in 1.1RC1, requiredif would
break
a javascript validator such as mask. I used custom validation instead.
<field property="prop1" depends="mask"><!-- removed requiredif -->
<msg name="requiredif" key="app224Form.aForm.prop1.req"/>
<msg name="mask" key="app224Form.aForm.prop1.mask"/>
<var>
<var-name>mask</var-name>
<var-value>${4dig}</var-value>
</var>
<!-- <var>
<var-name>field[0]</var-name>
<var-value>feeExempt</var-value>
</var>
<var>
<var-name>fieldTest[0]</var-name>
<var-value>EQUAL</var-value>
</var>
<var>
<var-name>fieldValue[0]</var-name>
<var-value>true</var-value>
</var>
<var>
<var-name>field[1]</var-name>
<var-value>prop1</var-value>
</var>
<var>
<var-name>fieldTest[1]</var-name>
<var-value>NULL</var-value>
</var>
-->
You can also check out the Validator doc on the struts documentation.
Just
expand the struts-documentation webapp that comes with your version of
struts, it is under User and Developer Guides.
-Kevin
--- Brian McSweeney <br...@aurium.net> wrote:
> Hi all,
>
> The validator package works well for me.
> But I'm trying to use the requiredif and failing.
>
> I know there has been previous discussion of this,
> but I'm trying to a simple validation based on a checkbox
> so perhaps someone could tell me where I'm going wrong.
>
> For example,
>
> I want to validate a creditcard, if a checkbox is checked.
>
> I currently am trying to do this as follows:
>
>
> <form name="myForm">
> <field property="creditCard"
> depends="requiredif,creditCard">
>
> <arg0 key="myForm.creditCard"/>
> <arg0
> name="creditCard"
> key="CreditCard"
> resource="false"
> />
> <arg0
> name="requiredif"
> key="A Credit-Card is"
> resource="false"
> />
> <var>
> <var-name>myForm.checked</var-name>
> <var-value>on</var-value>
> </var>
> </field>
> </form>
>
>
> The form name is: myForm
>
> The creditcard field is named "creditCard"
> The checkbox field is named "checked"
>
> Note that all other types of validation are working correctly for me.
>
> Any help would be SO much appreciated.
> Brian
>
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: requiredif - simple example
Posted by Kevin Robair <kr...@yahoo.com>.
The following worked for me. Note that in RC1, the <var-name> tag values
are expected to be field-test[n], not fieldTest[n] and so on....
The requiredif check was removed because in 1.1RC1, requiredif would break
a javascript validator such as mask. I used custom validation instead.
<field property="prop1" depends="mask"><!-- removed requiredif -->
<msg name="requiredif" key="app224Form.aForm.prop1.req"/>
<msg name="mask" key="app224Form.aForm.prop1.mask"/>
<var>
<var-name>mask</var-name>
<var-value>${4dig}</var-value>
</var>
<!-- <var>
<var-name>field[0]</var-name>
<var-value>feeExempt</var-value>
</var>
<var>
<var-name>fieldTest[0]</var-name>
<var-value>EQUAL</var-value>
</var>
<var>
<var-name>fieldValue[0]</var-name>
<var-value>true</var-value>
</var>
<var>
<var-name>field[1]</var-name>
<var-value>prop1</var-value>
</var>
<var>
<var-name>fieldTest[1]</var-name>
<var-value>NULL</var-value>
</var>
-->
You can also check out the Validator doc on the struts documentation. Just
expand the struts-documentation webapp that comes with your version of
struts, it is under User and Developer Guides.
-Kevin
--- Brian McSweeney <br...@aurium.net> wrote:
> Hi all,
>
> The validator package works well for me.
> But I'm trying to use the requiredif and failing.
>
> I know there has been previous discussion of this,
> but I'm trying to a simple validation based on a checkbox
> so perhaps someone could tell me where I'm going wrong.
>
> For example,
>
> I want to validate a creditcard, if a checkbox is checked.
>
> I currently am trying to do this as follows:
>
>
> <form name="myForm">
> <field property="creditCard"
> depends="requiredif,creditCard">
>
> <arg0 key="myForm.creditCard"/>
> <arg0
> name="creditCard"
> key="CreditCard"
> resource="false"
> />
> <arg0
> name="requiredif"
> key="A Credit-Card is"
> resource="false"
> />
> <var>
> <var-name>myForm.checked</var-name>
> <var-value>on</var-value>
> </var>
> </field>
> </form>
>
>
> The form name is: myForm
>
> The creditcard field is named "creditCard"
> The checkbox field is named "checked"
>
> Note that all other types of validation are working correctly for me.
>
> Any help would be SO much appreciated.
> Brian
>
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org