Bernd Schiffer wrote: > Hi Leon. > > I did what you mentioned as the second approach and used a token > (precisely: locking mechanism, because in my case it's not "delete" > but "edit") to avoid F5 problems. But I'm not happy with that, > because, you already said that, the user sees "edit.do" in the URL and > not "view.do", but "view.do" is the currrent action, and not > "edit.do", so it does not come up to user's expectations and that's > the major point, I think. Please let me know if you find a appropriate > solution. > > Bernd > > Leon Rosenberg schrieb: > >> 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?
You could forward to a list action. Something like this maybe. <global-forwards> <forward name="users" path="users.html" redirect="true"/> </global-forwards> <action-mappings> <action path="/users type="org.apache.struts.actions.ForwardAction parameter="/user.html"/> <action path="/user" type="org.springframework.web.struts.DelegatingActionProxy" name="userForm" scope="request" parameter="method" validate="method"> <forward name="list" path="userList.jsp"/> <forward name="edit" path="userForm.jsp"/> </action> That way even if they do hit the ole' F5 all it does is reload the list. If you want more information about doing this, or need to see some source code check out the equinox-struts example from: https://equinox.dev.java.net/servlets/ProjectDocumentList?folderID=2867&expandFolder=2867&folderID=2572 This app was found on www.raibledesigns.com/wiki/ Hope this helps. Brandon --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]