• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to call managed bean's method at startup  RSS feed

 
ym feng
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if i use commandButton, attribute action could be used to call binding method,
but how to achieve it, if the welcome file (e.x. faces/index.jsfx) be loaded at startup?
 
lynn fann
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
call the method in the constructor of managed bean. so when the page is loaded, the method will be called.
 
Piotr Swiecicki
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
lynn fann wrote:call the method in the constructor of managed bean. so when the page is loaded, the method will be called.


or implement a method annotated with the @PostConstruct annotation, so the bean will have access to all injected resources.
 
Bruce Riches
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Remember the managedbean's default constructor is called automatically by the JSF engine at application startup. So you can initialize, call methods etc from the constructor.

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!