This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes Struts : how to reload a Listing Page later. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts : how to reload a Listing Page later." Watch "Struts : how to reload a Listing Page later." New topic
Author

Struts : how to reload a Listing Page later.

Chetan Pandey
Ranch Hand

Joined: Aug 01, 2005
Posts: 31
I have a Requirement:

Customer enters search criteria in a Search Form and goes to a Listing Page of matching Rows.

Later at some point, click on a Link will bring me back to that existing Listing Page.

Since the Search Page is using POST method, how can I load that Page again when I have an option to save the Search Form-Object in Session.

I cant do Link + paramters that would be a Get instead of a Post
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30123
    
150

Why can't you use a GET? You aren't changing state; just running a query.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Chetan Pandey
Ranch Hand

Joined: Aug 01, 2005
Posts: 31
Because my Action was never designed to handle parameters.

I mean it has the following now in its execute():

id = formObject.getId();
country= formObject.getCountry();

etc.


This is beacause it is expecting a POST Method.

And as the page is designed this works.

But now I will either have to do a clumsy:

id = formObject.getId() == null ? request.getParameter("id") : formObject.getId();
id = formObject.getCountry() == null ? request.getParameter("country") : formObject.getCountry();
etc

which will be a patch-up hack to make the Action work with both get/POST.

And since this patternhas to be repeated for many many Actions, I will end up having a huge number of changes to existing actions and long change of manual form-element entries.


Anbarasu Aladiyan
Ranch Hand

Joined: Jun 02, 2009
Posts: 182

I am hoping that you are using struts2 and action class implementing the ModelDriven interface.
Pass all the field values while you are calling the action through links. Also make sure the parameter names in the link must match with field/variable names defined in the Bean/action variables. Thing is framework must be able to make Bean by using the parameters you are passing.
I think framework will take care of whether you are calling using Post or Get.


A.A.Anbarasu
Chetan Pandey
Ranch Hand

Joined: Aug 01, 2005
Posts: 31
Actually I am using Struts 1.3.10
 
jQuery in Action, 2nd edition
 
subject: Struts : how to reload a Listing Page later.
 
Similar Threads
Hold Form Data
How to handle a action on a link?
link css style sheet
How to hide the parameters in the URL??
Links without JavaScript