You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by xml spy <xm...@yahoo.co.uk> on 2004/10/30 21:31:43 UTC

conditional multibox validation using validwhen

I am trying to use validwhen with html multibox in
struts tag.

In my JSP I am using

a) A html:multibox which renders 4 check boxes for me
(using iterate tag). 
In my ActionForm this multibox property stores values
to a "String Array" property name "reasons" 

And

b) A text field of property name "dispatch"
 - This textfield "dispatch" will have only 2 string
values 
	Either “process" or "reject" (assume it gets
dynamically assigned these String values)

All I want to do is that to ensure no checkboxes are
checked when the text field dispatch=="process"

AND

All (or) at least one check box is checked when
dispatch=="reject"

I am aware of some integer comparison bug with 1.2.4
while using validwhen.

Now I am using 1.2.5 but none of my combinations seem
to work.

One of the combinations I tried is below mentioned.
This nearly works but does not ensure the checkboxes
are checked when dispatch=="reject"

<field property="reasons"
indexedListProperty="reasons" depends="validwhen"
page="1" >
<arg key="error.reasons.input" position="0" />
<var>
<var-name>test</var-name>
<var-value>(((dispatch == "process") and (*this* ==
null)) or ((dispatch == "reject") and (*this* !=
null)))</var-value>
</var>
</field>

NOTE: for some reason when I submit these 4 checkboxes
"UNCHECKED", they seem to be *NOT* NULL. They get
initialized to a zero length array. I am not
initializing the "reasons" property in the
struts-config.xml. So this property must be
initialized to null, which happens all fine. But when
empty unchecked check boxes are submitted the
"reasons" property is no more null but a zero length
array.

I would really appreciate if someone can just reply me
with a solution.

Many thanks in advance.


	
	
		
___________________________________________________________ALL-NEW Yahoo! Messenger - all new features - even more fun! http://uk.messenger.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org