• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts : how to reload a Listing Page later.

 
Chetan Pandey
Ranch Hand
Posts: 31
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Posts: 33691
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why can't you use a GET? You aren't changing state; just running a query.
 
Chetan Pandey
Ranch Hand
Posts: 31
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 182
Chrome Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 31
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually I am using Struts 1.3.10
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic