I think doing the post-redirect-get (the second option you mentioned) is the 
best way to solve your problem, according to what most people recommend.

Abdullah

-----Original Message-----
From: Leon Rosenberg [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 22, 2005 3:32 PM
To: 'Struts Users Mailing List'
Subject: The F5 problem - Best Practice (ActionHierarchy)


Hi,
 
I have a problem which I think is common to many of the developers one the
list, and where I'd like to hark to your opinions / solutions.
 
I think it's a common use case in web applications, where you have to
present a list of something, lets say a list of bikes.
You have normally some common functionality, like ShowList, Edit/New
(presents a dialog), Create/Update and  a Delete operation.
Now my problem is, that after delete,create or update I normally show the
updated list, by actually executing the Show action.
 
I know about two ways to implement this derive the delete action from show
action, and call super.execute(), or send a redirect from 
delete action to the show action.
 
Example: 
 
<action path="/bikesShow" type="net.anotheria.bikes.action.ShowBikesAction"
scope="request">
        <forward name="success" path="/net/anotheria/bikes/jsp/Bikes.jsp"/>
</action>
<action path="/bikeDelete"
type="net.anotheria.bikes.action.DeleteBikeAction" scope="request">
        <forward name="success" path="/net/anotheria/bikes/jsp/Bikes.jsp"/>
</action>

After bikeDelete has been called, it calls the super.execute from
ShowBikesAction it's extending, and the updated list is presented. Works
fine ... until the user hits the refresh button. Since the url in the
browser is bikeDelete and not bikesShow the delete 
action will be called again. It's getting even worser with create action
which then would actually create a second record.

Now, I could avoid creating second object or trying to delete already
deleted object by inserting an execute-once-tokens, but it feels
like fixing a bad design, so I'd like to avoid it.

Another approach I know of, is to define the delete action without a forward
and actually send a redirect after the deletion is complete. This would
solve the F5 problem, but produces an additional request from browser to
server, and makes the whole app slower.

Do you know any other solutions? I have searched for an opportunity to solve
this problem with a tricky js, actually replacing 
the url of the current document in the browser without request, but i found
none :-(

Any other ideas, options? 

Thanx in advance

Regards
Leon





---------------------------------------------------------------------
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]

Reply via email to