Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Initialization during application start-up  RSS feed

 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi:

In JSF do we have something similar to Plugin interface in Struts where we can initialize resources,set values in context during application start -up.Thank you for your responses.

Thanks
 
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can write a servlet context listener. Hope the below link might help you.
http://www.onjava.com/pub/a/onjava/2001/04/12/listeners.html
 
Bartender
Posts: 19660
92
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have a number of options. One of the simplest is to define a bean with application scope. This is actually an ideal place to hold application-wide values, since you can inject initialization values via the faces-config file without having to change the program code.

One of the things I use this for is when I have an app with dropdown lists whose items are constant values loaded from a database. I hit the server once at app startup and pass the lists back as needed. I can refer to them directly in JSF pages or inject them into session or request-scope beans.

Spring also has its uses. I use it to construct the DAOs and other persistence-layer object. By linking Spring and JSF, I can then inject these objects into the JSF objects,
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!