Anil Kumar T wrote:
Hi Group,

I need a help on general issue which every body would have solved.

Generally we'll have four operations like Add, Update, Query and Remove.
I believe we can use DispatchAction to handle all these operation in a
single action. So for the validation part we are planning to use
validator framework. Generally for create we will need to validate all
the mandatory fields (not the PK value incase of DB sequence) and for
update all the fields including the PK fields(as hidden fields) and for
query there may not be any validations and for delete operation we need
to validate the PK value alone. I'm not sure whether we can achieve this
kind of validation using validator framework or not. Because from my
understanding I believe that validator framework would be invoked first
and then the Action class. So can we validate the fields on conditional
basis?

I think we can do this by writing each operation in different action
calss.

Or is there a better approach for this kind of scenarios. Any help,
information, links material would be helpful.

There are a few options here. The simplest may be to call validation manually (set validate="false" in your action mapping, and call form.validate() somewhere in your action's execute() method). That gives you the most control.

Alternatively, the validation framework has support for 'multiple page validations' designed for wizard-type workflows. You could use that to select a set of validations based on which action was being performed (treating different actions like different pages in a workflow).

Another option may be to use validwhen validation rules, but since there's no easy way to conditionally invoke other rules (like required, integer, etc.) from a validwhen rule, this approach would probably get pretty messy...

If you have different action mappings for each operation, there's an easier option though: in that case, you can map your validation rule sets using the action mapping path instead of the form name -- in other words, apply different validation rules for /addFoo, /updateFoo, /queryFoo and /removeFoo whilst using the same form bean for each. To do that, you need to subclass ValidatorActionForm instead of ValidatorForm.

L.



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to