Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

Force a reload after form submit?

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello - this may be a simple question - I'm new to struts and have been figuring out ways to do what I want, but I'm afraid that there are often better ways to do them using struts.

My current problem is as follows:

I have a form bean which contains a Collection of items. I print out the list of items, each with a checkbox to delete them (essentially the same idea as a shopping cart with 'remove from cart' checkboxes). So the user can check n boxes, and hit the delete button which submits the form with the appropriate parameter.

The action class actually does the work of deleting the items (the mechanics are unimportant). I simply want the resulting page to show the list of items, minus the ones that were just deleted. However it doesn't do this until I refresh the page.

I've tried using forwards in struts_config.xml file (i.e. returning mapping.findForward("delete_success") from the execute() method in my Action class after the deletion is successful), but I want the page to which I'm forwarded to to include the original page (list of items). It's never up to date until I refresh. I can confirm that the items are deleted.

I'm not sure if this is some caching problem or a simple struts thing that I'm missing.

I assume this is a common task, as every shopping cart system must work this way.

Thanks for any advice.
 
Ranch Hand
Posts: 354
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you have a /cart/view.do (or something like that) to present the cart initially correct? in your action mapping for the cart update action then forward it to that /cart/view.do. ex:

<action name="/cart/delete.do"....>
<forward name="delete_success" path="/cart/view.do"/>
</action>

if you're already doing this, it's a caching issue. you can test it out by disable caching for the entire app by setting the controller property in the struts config as follows:

<controller>
<set-property property="nocache" value="true"/>
</controller>

this will disable caching for the ENTIRE app, which may not be desirable. you can modify the Action class to selectively disable response cache.
 
Tongue wrestling. It's not what you think. And here, take this tiny ad. You'll need it.
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!