Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Bean gets instantiated again in one request  RSS feed

 
sanju dharma
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am new to JSF and going through very simple tutorial right now. I input my name on first page which i display it on next page. But surprisingly, the mapped bean gets destroyed and new bean instance is created in one request. So returned data from the bean on next page is always null. Here is very simple code.

inputname.jsp



greeting.jsp ( just to display name entered on the previous page )

 
Tak Ng
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Open faces-config.xml and check if you have the option "<redirect/>" in the navigation-rule between these two pages. In the case that "<redirect/>" is present, please comment it and test again.
 
Gabriel Claramunt
Ranch Hand
Posts: 375
Monad Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check also the scope of the bean, if is "request", you'll get a new one each time the page is loaded. If you set the scope to "session", it will keep the values until you finish your session.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!