Struts validator question

N

nooobody

I am just learning the Struts Validator and have been asked to use it
in a new application I am working on. I have it working fine for a
simple form but the next form is not so easy.

The form is set up as so: 4 radio buttons, each with a textbox beside
it. Validation errors are to be displayed just below the textbox that
is in error. The logic is: whichever radio button is clicked, the
content of the corresponding textbox must be at least one character,
and must exist in the database.( requires a database call). The
message displayed when the textbox is empty is different from the one
displayed when the item is not found in the database. The other
textboxes are ignored ( likely they'll be disabled).

I wanted to use the validwhen validator but I have not found a way to
save an error under a unique key such that it may be identified and
displayed under the correct textbox. I have already written the
validation code and tested it in the action class. I've now moved it
to a class that contains only validation methods. I need to know if
there is a way to duplicate something like this:

errors.add("uniqueNameToSaveErrorUnder", new
ActionError("errors.whatever.rmessage"));

by specifying the correct value for an attribute, either in the
validator configuration or in the form/field configuration.

Thanks

Tim
 
S

Sudsy

nooobody wrote:
I wanted to use the validwhen validator but I have not found a way to
save an error under a unique key such that it may be identified and
displayed under the correct textbox. I have already written the
validation code and tested it in the action class. I've now moved it
to a class that contains only validation methods. I need to know if
there is a way to duplicate something like this:

errors.add("uniqueNameToSaveErrorUnder", new
ActionError("errors.whatever.rmessage"));

by specifying the correct value for an attribute, either in the
validator configuration or in the form/field configuration.

I believe that validwhen is overkill for your application. See some
examples in this article:
<http://www.sudsy.net/technology/validation.html>
If you still have problems, post the contents of your validator.xml
and JSP files.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top