File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 Groovy Fundamentals video training course this week in the Groovy 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

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
author & internet detective

Joined: May 26, 2003
Posts: 32077

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

[OCA 8 book] [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();


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();

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.

Chetan Pandey
Ranch Hand

Joined: Aug 01, 2005
Posts: 31
Actually I am using Struts 1.3.10
I agree. Here's the link:
subject: Struts : how to reload a Listing Page later.