File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes Initialising request scoped bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Initialising request scoped bean" Watch "Initialising request scoped bean" New topic
Author

Initialising request scoped bean

gary stines
Greenhorn

Joined: Mar 11, 2002
Posts: 19
Can someone explain the following behaviour

I have two pages page1.jsp and page 2.jsp each with managed beans called page1 and page2 respectively in the request scope as shown below


page1 has a selectOneMenu. I also have a command button on page1 which goes to page2. Page2�s purpose is to collect information to add a selectItem to the selectOneMenu on page1.

Partial code shown below, values hardcoded for clarity. The idea here is to save the contents on page1 in some session scoped object, in the page2 action method create a fresh page1bean, update it with the original values, then redisplay page1 with the newly updated values



When I am returned to page1.jsp I see the selectOneMenu list has been updated and everything looks fine. The problem occurs when I then hit the submit button on the redisplayed page1. The item I added disappears from the list.

What�s happening here?

The only happens with the selectOnemenu component. Other inputText components work fine.
[ May 12, 2005: Message edited by: Gregg Bolinger ]
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Please use Code Tags in the future. It makes code so much easier to read. Most people won't even try and look at your code unless you have used code tags.

I edited your post for this purpose.


GenRocket - Experts at Building Test Data
Jeremy Wilson
Ranch Hand

Joined: Feb 18, 2003
Posts: 166
What I do it change from the request scope to session scope. If the managed bean is used across multiple pages this is the way I have seen it done and works for me. I normally add a reinit() method to call when I am done with the bean since it remains with the session.


Jeremy Wilson
gary stines
Greenhorn

Joined: Mar 11, 2002
Posts: 19
Session scope for page1 would work. But can anyone still explain the behaviour as mentioned before.

(Thanks for the reformat Gregg)
Varun Khanna
Ranch Hand

Joined: May 30, 2002
Posts: 1400
How is your list in page1 populated? through some session variable I believe ? then on page two are you updating that session variable in addition to adding a new select item in the list?

Your question will be more clear if you can provide more code to look at.


- Varun
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

I'd love to test our your problem however I don't feel like creating the entire app from scratch. If you could provide me with your page1.jsp, page2.jsp and appropriate backing bean(s) I can then plugin some static values for the dropdown(s) and see what the problem is.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Initialising request scoped bean