File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes How to separate it out prepare and process Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Reply Bookmark "How to separate it out prepare and process" Watch "How to separate it out prepare and process" New topic
Author

How to separate it out prepare and process

Mark Henryson
Ranch Hand

Joined: Jul 11, 2005
Posts: 200
I am developing an application using Struts 1.3.10.
I want to know how to achieve the below thing in struts.

For example:
On clicking the link, I am loading the jsp page with some lookup values (prepare)
After page loaded, user will submit the details and will submit for DB (process).

I have used the below two approach:

1. Written one BaseAction which extends the Action and written two abstract ActionForward methods, one for prepare and another one for process.
2. In BaseAction of execute method, it will choose either prepare or process method using the request parameter.
3. All other application related Action will extend this BaseAction with (?method=prepare or process).
4. I don't want to use any hidden variables in my application. If I am using the above approcah I need to use the hidden variable for passing method as "process" while user submits the form.

I have also tried with Dispatch action, which are more or less follows the above approach with the parameter will be the part of the form.

or

Whether separate action for prepare and process will solve the problem?
Please advice the best approach to use.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

When I used S1 I almost always used a base class that differentiated between GET and POST requests, and all form submissions were POST. I had prepareGet() and preparePost() methods (although I almost never used both), called validation manually, and if it failed (usually) called prepareGet() to reload any lists etc. needed on the JSP.

Something similar may work for you.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: How to separate it out prepare and process
 
Similar Threads
Referring Page in Struts
getting id, not value from form element
Cannot set attribute in request in jsp
Struts Validator and Dynamically Populated Select Lists
Assigning String object to bean class reference variable/jsp:usebean issue