wood burning stoves
The moose likes Struts and the fly likes Problems with checkbox using Struts Validation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Problems with checkbox using Struts Validation" Watch "Problems with checkbox using Struts Validation" New topic

Problems with checkbox using Struts Validation

Davide Alagna

Joined: Feb 16, 2005
Posts: 5
Hi everybody, I have two problems with my Struts application. I have a checkbox that disables an input:text when checked (I use a simple javascript to do that). My problems are:

1) I want my DynaValidator to validate the input:text only if it is not empty and the checkbox is not checked, but I can't find the right expression for the "validwhen" property. Actually it is:

<field property="text_name" depends="validwhen">
<arg0 key="myform.mytext_name" />
<var-value>((checkbox_name == null) and (*this* != null))</var-value>

but i don't know how to validate the "" string.

2) when validation fails, the validator calls back the page. The checkbox will still be checked, but the input:text will not be disabled.

Could you help me? Thanks in advance. David
Marc Peabody
pie sneak

Joined: Feb 05, 2003
Posts: 4727

null will also check for empty string ("")

See the bullet item for null.
"* The value null which will match against either null or an empty string "
[ February 16, 2005: Message edited by: Marc Peabody ]

A good workman is known by his tools.
I agree. Here's the link: http://aspose.com/file-tools
subject: Problems with checkbox using Struts Validation
It's not a secret anymore!