• 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
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

Initialize backing bean

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Can anybody tell me when does an object of a backing bean(in request scope) get created ?
I have a few components in my jsp page,which have corresponding action listener defined in the backing bean. I have observed that a new instance of my backing bean (i.e the @PostConstruct getting called) is getting created for each events those fired from my UI.
Actually I have a DB call in my init() method which is annotated with @postconstruct.
But this method is getting called for each events that are getting fired and hence calling the DB each time. I want to avoid this.

Can anybody help ?

Shaiju
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When ever a JSF page is submited the beans which all are mentioned in the JSf page will be initiated if the bean scope is in request. This is how JSf behave. If bean scope is in session the bean will be intiated for every session.
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Request scope object will create new instance every time when requested from UI/ an event is fired !!!

So set the backing bean object in Session scope.
 
Rototillers convert rich soil into dirt. Please note that this tiny ad is not a rototiller:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic