Hi Nic,

Struts does not allow to do things like this declaratively, but you
can do it manually.

1) you can obtain mapping name from the ActionMapping. This will
solidify the mapping name where you want to return, in code. I am not
sure that this is worse that to solidify it in struts-config.xml, but
people say that struts-config.xml is "more flexible in deploy time".
Hardly.

2) You can set the params too, it is not a big deal. Do not edit
existing ActionForward from findForward, instead create a new one and
append query parameters.

Referer is a great thing, but some browsers and firewalls can turn it
off, so it is not reliable.

On the other hand, are you sure that you want to design your actions
like this? How about this:

* createItem - creates new empty item; forwards (better yet,
redirects) to editItem.
* editItem - allows to set/change value for a new or for an existing item;
* storeItem - persists modified item (inserts the one just created or
updates already existing, called from editItem);

But in this case, if you use redirection, you would need to patch the
path to the action too, to include item ID. If interested, see more
here: http://www.theserverside.com/articles/article.tss?l=RedirectAfterPost2.
It has a link to the source code, too.

WBR,
   Michael Jouravlev.

On 4/18/05, Nic Werner <[EMAIL PROTECTED]> wrote:
> Hi again,
>     I'm calling the validate() method in my MappingDispatchAction to
> check errors on page. Which is fine, except that I want to return to the
> URL (Action w/params) that was called. I have two Actions, Edit and Add,
> which both refer to Attributes.jsp, and depending on the type param set,
> this page forwards to either Update or Insert, respectively. Therefore,
> setting 'input='Attributes.jsp' won't work as the bean isn't setup
> properly for the Edit Action.
>     So, the flow is that I want '/Edit.do?Id=32' to check for errors,
> and if there is one, return to '/Edit.do?Id=32', not Attributes.jsp. It
> isn't enough to set the type (Edit/Add) in the session scope, I would
> need to set the params also, which seems like more complex
> handling/overhead.
>     Is there a solution workaround to this? I've searched, and of course
> Rick has written some good articles on this, but I haven't seen the
> situation where it needs to return to a dynamic page *with* the params,
> aka the calling page.
> 
>     I suppose I could get the referer URI, but I don't think I could
> call mapping.getInput() that way.....
> 
> Thanks,
> 
> - Nic.

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

Reply via email to