Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Action to Action Forward

 
O. Thoms
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 948
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic