Hi Jacob,
I asked almost the same question when we were implementing validation. We
had the same issue with preparing things before creating the user page. We
ended up creating an input that forwarded to a mapping that was basically a
duplicate of the one with the validation failure. The only differences
were (1) There was no validation in the second mapping and (2) the second
mapping used a different parameter so that we could return to the exact
page (edit/create) that created the validation failure.
You are on the same path that we used. It isn't as elegant as it could be,
but it is less code than if we did it all "by hand".
I don't know if I have the right class name, but I would think that you
could extend the RequestProcessor and have it behave a little differently
when the validation fails...
Nick
|---------+---------------------------->
| | Jacob Weber |
| | <[EMAIL PROTECTED]|
| | .com> |
| | Sent by: news |
| | <[EMAIL PROTECTED]|
| | rg> |
| | |
| | |
| | 05/16/2004 12:31 |
| | PM |
| | Please respond to|
| | "Struts Users |
| | Mailing List" |
| | |
|---------+---------------------------->
>------------------------------------------------------------------------------------------------------------------------------|
|
|
| To: [EMAIL PROTECTED]
|
| cc:
|
| Subject: Re: Using DispatchActions with validation
|
>------------------------------------------------------------------------------------------------------------------------------|
Right, the flow returns to the "input" page, which can be another action
call. So I'm making my "input" point to "/myAction.do?method=myMethod",
which calls a particular method of a DispatchAction.
It seems to work, but this kind of points to a larger question. Say I
have some steps that need to be taken before displaying a form. For
example, I might need to prepare the values in a drop-down menu.
If the user submits the form and the Struts validation fails, it will
re-display the form, so I'll need to run this prep method again. This
means I'll need to point the input parameter to an action (or a method
of a DispatchAction).
As a result, for every form, I'm going to need two action-mappings
defined in the struts-config file. One has validate="true", and its
"input" points to the other action. That one has validate="false", and
it simply prepares the form for display.
Is this right? I would expect Struts to handle this a little more
elegantly.
Jacob
In article
<[EMAIL PROTECTED]>,
"Wang, Yuanbo" <[EMAIL PROTECTED]> wrote:
> Correct me if I am wrong, I don't know if this is ever possible. If the
> validation method in ActionForm class returns a not null ActionErrors
> obj, the flow will direct to "input" page, so if you really want to
> invoke something in this case, my bet is that you have to put that logic
> inside your ActionForm.validate method?
>
> Any idea?
>
> Thanks,
> Yuanbo
>
>
> -----Original Message-----
> From: news [mailto:[EMAIL PROTECTED] On Behalf Of GMaine
> Sent: Friday, May 14, 2004 12:31 PM
> To: [EMAIL PROTECTED]
> Subject: Using DispatchActions with validation
>
>
> I have a DispatchAction with two methods. I pass a hidden field "method"
> in my form, to determine which method should be called. But I want to
> override this and call a specific method if the form's validation fails.
>
> Is it legitimate to put this in the action mapping?
> input="/myAction.do?method=myMethod"
>
> Or could this conflict with the "method" hidden field?
>
> Jacob
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]