• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Struts ActionForm problem....

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am developing "search" functionality in my "struts-powered"
application. I have implemented two Action classes (one navigates a
user to the Search form and the other actually runs the search). On
the Search Results screen, the user has two options: Modify Search
and New Search.
So far so good. However, when the user requests a New Search, I
cannot seem to restore the Search form to its "new" state i.e. with
all the search criteria fields nulled out.
I have tried calling the form's reset method from within my
NavigateSearchAction class, but from what I gather from going through
the Struts ActionServlet source code, it re-populates the form
between Action calls. Essentially, it retains form "state" between
two requests. This is great, but what if I want my form state to be
changed in between two requests?
If anybody has any ideas, would deeply appreciate it.
 
Saloon Keeper
Posts: 27808
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're probably defining the form bean with the wrong scope. Actually, the reset method should initialize the form bean to the values you select - though there is a special care you must take when working with boolean controls and form beans.
However, a form bean in request scope is going to be overlaid with values coming in from the request by the master dispatcher servlet BEFORE your action class's perform() is invoked.
 
Keshav Deshpande
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tim:
You da man!
You were right, I had the scopes all wrong. I have it working all right now.
Now that I look at it, the scopes I had set up earlier was just plain stupidity on my part.
Anyway, thanks for the tip.
Cheers,
Keshav
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic