• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

JSF: Bean Instantiation

 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I have a page as simple as a form with a single text field and a submit button, all done in JSF of course. And then I have a JavaBean for this form. When does this Bean get instantiated? When the form is accessed or when the form is submitted, none of the above?
Thanks.
 
Author
Posts: 234
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Greg,
It depends on how its specified in the faces-config.xml
<managed-bean-scope> session </managed-bean-scope>
will put it in the session and it will be created when the bean is first accessed.
Hope this helps...
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Bill Dudney:
Hi Greg,
It depends on how its specified in the faces-config.xml
<managed-bean-scope> session </managed-bean-scope>
will put it in the session and it will be created when the bean is first accessed.
Hope this helps...


Well, at what point is the bean first accessed? When I view the form or when I submit the form? And in addition to that, is it my responsibility to remove that Bean from the session if/when I don't need it anymore?
[ March 04, 2004: Message edited by: Gregg Bolinger ]
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It would appear, after a little testing, that the Bean is accessed the first time when the Form is accessed for the first time since you are specifying a value for the textfield.
 
Bill Dudney
Author
Posts: 234
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Greg,
You got it, when the page renders for the first time...
 
They weren't very bright, but they were very, very big. Ad contrast:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic