• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Initialising request scoped bean

 
gary stines
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jeremy Wilson
Ranch Hand
Posts: 166
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
gary stines
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1400
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic