Letícia Álvares Barbalho wrote:
Hello everyone,
I'm working with smart forwarding in my application. I have an action with
this mapping in struts-config:
type="auge.action.DeterminaAction"
name="addDelUpdColecaoForm"
validate="true"
input="/pages/colecao/colecao.jsp">
scope="request" >
The actions for which it forwards are configured like this one:
name="addDelUpdColecaoForm"
scope="request"
validate="true"
input="/pages/colecao/colecaoDados.jsp">
As you can see, the second action has a different input page. It is because
is I have 3 actions to which I will forward and one of them has a different
input page. So, when the validator returns me an error, and returns me to
the input page specified at "DeterminaColecao", and not at the action
executed. I tried ommiting the "input" option at "DeterminaColecao", but
then it returns me an error instead of using the action input.
Is there any way my html:form could call the "DeterminaColecao" but use the
input page of the action to which it forwarded?
Thank you.
You can't get exactly what you want, since that doesn't fit the processing
model. What happens is, your form submits to /DeterminaColecao and, since
you have validate="true", validation occurs before your action executes. If
validation succeeds, processing proceeds into your action and you can
forward to wherever you want. However, if validation fails, the /UpdColecao
action doesn't get called. At this point, there's no way for validator to
know where your action would have forwarded to had the /DeterminaColecao
action executed, so it can only forward to the current (/DeterminaColecao)
action's input page.
To do what you want (have /DeterminaColecao forward to different input
pages depending on what the next action would have been), you will need to
override validate() (calling super.validate() to invoke validator) and have
your /DeterminaColecao action perform the forwarding when validation fails.
Another option you may be able to use would be to turn off validation on
the /DeterminaColecao action and rely on validation in each of the actions
it forwards to. Since you're not specifying redirect="true" on the
forwards, the action you forward to will see the same request data as the
/DeterminaColecao action and can validate after the forward. That's only an
option if you don't mind /DeterminaColecao executing against invalid
inputs, though. If that's not acceptable you'll have to use option one.
L.
--
Laurie Harper
Open Source advocate, Java geek: http://www.holoweb.net/laurie
Founder, Zotech Software: http://www.zotechsoftware.com/
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]