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
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