• Post Reply Bookmark Topic Watch Topic
  • New Topic

what should the scope of the ben associated with form in jsf  RSS feed

 
hemamalini nithyanandam
Ranch Hand
Posts: 53
Chrome Eclipse IDE MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a managed bean for a form. I map the fields filled in the form with managed bean properties. when I submit the form and click new form , values from the previous form submitted gets displayed in the input fields. I used the scope of the from bean to session. what should be its scope so that values should be destroyed after I submit the form .For every new form ,new bean has to be initialized. On submit I navigate to another bean with session scope.
 
K. Tsang
Bartender
Posts: 3648
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For simple form submission, I use ViewScope.

SessionScope is used, for me anyway, when the page has a "pagination" table or the form consists of several pages (eg the final submit is on say page 3).

The difference between view scope and session scope from my experience as I recall is that:
* Under view scope the constructor of the managed bean gets called every time (like making a new instance on every access)
* Under session scope constructor called once (the very very first access) = don't know if JSF managed bean session actually mean the HTTP/web app session

 
hemamalini nithyanandam
Ranch Hand
Posts: 53
Chrome Eclipse IDE MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks a lot
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!