It's not a secret anymore!*
The moose likes Struts and the fly likes declaritive validation - validwhen Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "declaritive validation - validwhen" Watch "declaritive validation - validwhen" New topic
Author

declaritive validation - validwhen

Jan Groth
Ranch Hand

Joined: Feb 03, 2004
Posts: 456
hello,

i have the following constellation:

a group of three radiobuttons, each of them with a text-field next to it.



if a radio-button is clicked, i need to check that according text field is filled out and contains a valid float. (required, float)

even though "validwhen" looked pretty good on the first glimpse, i'm unable to find out the configuration for my problem.

here the generalized question again:
how can i trigger certain validations in dependence of a test?

thanks a lot for any help,
jan
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Try this:

This will only work if the float check accepts a blank value, which I'm not 100% sure it will. Give it a try anyway. Also, if radio1 is a boolean, substitute radio1 == false in the above code.
[ September 27, 2006: Message edited by: Merrill Higginson ]

Merrill
Consultant, Sima Solutions
Jan Groth
Ranch Hand

Joined: Feb 03, 2004
Posts: 456
hi merril,

thanks for you answer...

this solution does not work... it will start the float validation if the radiobutton is not selected (radio1 == null). this might be tolerable for a float validation, but is not possible for a required validation.

the problem is that with validwhen i can only define a "exit point" before following validations:

( "validwhen, x, y" will not execute x and y if validwhen is not valid)

but i can't seem to write something like validatewhen, which would only execute x and y if validwhen computes to true.

looks like i need to code it by hand,

jan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: declaritive validation - validwhen
 
Similar Threads
Help with validwhen rule
Validating text field only when the another text field is present
struts validation
Checkbox and Multibox validation
displaying error message but not validating