commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Niall Pemberton" <niall.pember...@gmail.com>
Subject Re: [Validator] Validator usage with DispatchAction
Date Wed, 02 May 2007 15:11:34 GMT
On 5/2/07, Kenneth Ballard <kballard@bcgi.net> wrote:
> I was looking at that this link
> (http://struts.apache.org/1.x/struts-extras/dispatchValidator.html)
> about using the "page" attribute when validating forms submitted for a
> Struts DispatchAction so that only certain fields are validated when
> submitting a form for a particular method of the DispatchAction. The
> technique is recommended for use with wizard-like flows so the "page"
> attribute refers to the sequence of the step in the flow. But what about
> the case where you have grouped a set of logically related Actions into
> a single DispatchAction (and they share the same coarse-grained
> ActionForm) but there is no flow? Is it also recommended that you use
> this technique in these sorts of cases? The major difference is that
> there is no set sequence of steps (i.e. a user might only use a method
> or two of the DispatchAction in a given use case) so the "page"
> attribute just functions as a unique identifier of the validation. Is
> this considered proper usage of Validator? Are there any problems with
> this approach?

I don't think using the "page" attribute is going to work for you
since validation occurs for all pages up to the current - so for
example if you say the current page is "4" then all fields configured
with a page number equal to OR less than "4" will have their
validations triggered.

In your scenario I believe you have two options:

1) In the ValidatorForm
Provide a custom implementation of the getValidationKey method. The
downside to this is that you have to duplicate the logic of your
dispatch action which works out which method needs to be invoked.

2) In the dispatch action
Set valdiate to "false" for your action mapping and initiate the
validation yourself from the action passing the appropruite key - look
in the ValdiatorForm for what needs to be done for this.

Neither solution is ideal and works "out of the box" for you.

Niall

> Thanks,
>
> Ken

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message