Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Two jsps having same form beans are similar or not

 
ajay bora
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am facing a big problem with two jsps which are having the same form bean. I am linking up three jsps which are having the same form beans as a series of steps. So the user can traverse these steps until completion . There is a sequence of back and forward buttons for each jsp. So they can navigate front and back. The problem i have is that once a user finishes step1 and goes to step2 and then if he clicks previous button to go to step1 the values he submitted are gone . In order to solve this problem i had to use sessions in action class and pain stakingly i stored all the beans in sessions and retrieved values from them and set up in the forms for navigation . I am wondering whether i am thinking in the right direction or i am wrong some where . Please help me . Are the beans supposed to be the same even if multiple jsps have the same name or each one is different.

JKPS Layout

Step1 --> 1.jsp Step 2 --> 2.jsp Step 3 --> 3.jsp

baseform is the form common for all jsp's

baseform has 3 VO's for storing values in forms
like one ,two ,three

so baseform is in this form

public class baseform extends ActionForm{

OneForm one;
TwoForm two;
ThreeForm three;

}

OneForm VO is used for assiging the values in 1.jsp
like <html:text name="username" property="baseform.one">
1.jsp has elements like
<html:text name="username" property="baseform.two"> and so on
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Specifying scope="session" for each of the action mappings that use this form is a good way to go. If you want to navigate between these pages and have them retain previously entered values without writing to a database, using the session is your best option.
 
Brent Sterling
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems like you have three basic options.

1) Configure your action to use request scope and store every submitted value as hidden fields on each of your three jsp pages. This solution can get ugly and you might end up passing a lot of data back and forth with each submission.

2) Configure your action to use session scope per Merrill's recommendation. This is probably the easiest way to implement wizard-like functionality.

3) Write your own code to store data in session. With this approach you have to update the session data with each page submission. This can be a hassle if your page has a lot of fields, but easy if your page just has a few selections. This is the approach that I have taken.

- Brent
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic