This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes JSF and the fly likes refreshing a form with bean values when returning to jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » JSF
Reply Bookmark "refreshing a form with bean values when returning to jsp" Watch "refreshing a form with bean values when returning to jsp" New topic
Author

refreshing a form with bean values when returning to jsp

Stuart Rogers
Ranch Hand

Joined: Oct 02, 2008
Posts: 123
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

Joined: Jun 21, 2008
Posts: 80
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

Joined: Jul 30, 2008
Posts: 43
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


The woods are lovely, dark and deep, But I have promises to keep; And miles to go before I sleep, And miles to go before I sleep. - Robert Frost
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: refreshing a form with bean values when returning to jsp
 
Similar Threads
Dynamic Hyperlink--How to??
clear session scoped variable values
How to update Session variable with Form Data ?
Sequencing Question
URGENT Help Needed ...!!