Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

refreshing a form with bean values when returning to jsp  RSS feed

 
Stuart Rogers
Ranch Hand
Posts: 141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ye gods, where to begin...

Tomcat-jsp-jsf-beans

I've a aa.jsp that contains a form whose data comes from a bean bb.java that has a handler bbHandler.java .
The form has a "Submit" button to save the form field values to the bean and onward to the SQL table. All pretty standard stuff.

When I first open my app and go to aa.jsp, bbHandler creates an instance of bb, populates the instance with data from an SQL table, then fills in the form fields with data from the bean.

So far so good.

Suppose the user fills out a few form fields then navigates away from the page withOUT submitting then later navigates back to the page - I'd like the user to see all the original values from the bean in the form INSTEAD of seeing the form as the user last left it.

Put another way, I'd like the page to populate the form with data from the bean every time the user navigates to the page . How can I achieve this?


TIA,

Still-learning Stuart

 
Hany Shafik
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Would it be possible for you to post your code.
However as I understand from the problem described above, I think the answer relies in the scope of the bean and how do you navigate out of your form.
If it is session scope and a commandButton (or commandLink or any component whith similar behavior) is used to do the navigation out of your form with no immediate attribute set to true then you will probably face this problem.
 
Sumeet Singh Aryan
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hany is right. It seems that the problem is with the managed bean scope. check in your faces-config.xml file and check the scope of your bb.java bean. try to put the scope as "request". This will hopefully solves your problem
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!