wood burning stoves*
The moose likes Struts and the fly likes Action to Action Forward Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Action to Action Forward" Watch "Action to Action Forward" New topic
Author

Action to Action Forward

O. Thoms
Greenhorn

Joined: Nov 21, 2006
Posts: 10
Hi,

Im having a SearchForItem Action witch runs on SearchCriteriaForm and provides the results for a itemList.jsp.

Now the list contains a Link for every 'available' item wich leads to a RequestForItem Action.

When the RequestForItem Action is done I jump back to the list again.

Since it's a bigger concurrent system my idea was to store the SearchCriteriaForm in the session context and then forward from the RequestForItem Action to the SearchForItem Action to update the result(list) since the call of RequestForItem Action itself changed my system as well as other users could have.

I want to save the user the trouble of entering all search criteria again, simply refetch from the DB and redisplay the changed list. And of course reuse my SearchForItem Action code, why implement it a second time.

But it doesn't seem to work.





and of course in RequestForItem:
ActionForward af = null;
...
af = mapping.findForward("/search");


Any hints?
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948


I would probably remove the "/" from the name attribute, but I don't know if that will make a difference. Your path attribute should include ".do", like "/search.do".

- Brent
O. Thoms
Greenhorn

Joined: Nov 21, 2006
Posts: 10
Sorry, the slash is OK. The application runs fine so far.

I skipped the framework info: It's in a Portlet container and all the .do forwarding renaming blabla is done by the framework.

The Forward "/search" works fine in the MenuAction...

But I solved the problem in a more elegant way anyhow.

I switched to a cleaner, more layered design and removed the search implementation from the Action in a 'Command' using the Command Pattern.

Action just takes JSP input, calls commands and get's results

Now executing the new search is just a single line of code issuing the SearchCommand again.

Sometimes it pays of to build a clean architecture..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Action to Action Forward
 
Similar Threads
Stop multiple posts
html:link with bean:define param, value gone in action ?!
Server-side validation causing bean data to vanish.
ArrayI ndex OutOfBoundsException when page refresh
Error:java.lang.IllegalArgumentException: No bean specified