Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

struts: validwhen problem

800340Oct 14 2006 — edited Oct 16 2006
hi guys,

so I'm using validator.xml to check my form.
In short: If the user will send a check - don't check for creditcard info. but if the checkBox is not checked- validate the nameOfuser on creditCard.

I need an 'if statment' and I do the following with validwhen:

struts-config.xml
<form-property 	name="check"  	  			 type="java.lang.String"  initial=""/>
<form-property 	name="nameOnCreditCard" 	 type="java.lang.String"  initial=""/>   
jsp:
		<td>
			<html:checkbox property="check" value="true">Will send a check</html:checkbox><br>
			<html:errors property="check" />	
		</td>
validation.xml
            <field property="nameOnCreditCard" depends="validwhen">
            <arg0   key="error.nameOnCreditCard.required"/>   
		        <var>
		          <var-name>test</var-name>
		          <var-value>((check == false) or (*this* != null))</var-value>
		        </var>           
            </field>           
so basically I'm asking this: if the user clicks the checkBox - will send a check - DO NOT CHECK for nameOnCreditCard (if it's empty - that's ok)

for somereason, any combination I'm trying doesn't work!!!
((check == false) or (*this* != null))
((check == true) or (*this* != null))
(check == false) 
(check == true) 
((check == 'false' ) or (*this* != null))
((check == 'true') or (*this* != null))
((check == '1 ) or (*this* != null))
((check == 1) or (*this* != null))
in other words, even if the checkbox is clicked or not (and it's working i checked) the nameOnCreditCard has an empty error message (suppose to show an error message if the checkBox is not clicked)

anyone?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 13 2006
Added on Oct 14 2006
2 comments
176 views