File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes Initialization during application start-up Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Initialization during application start-up" Watch "Initialization during application start-up" New topic

Initialization during application start-up

Venkatesh Kumar
Ranch Hand

Joined: Aug 08, 2003
Posts: 68

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.

Venkat Sadasivam
Ranch Hand

Joined: May 10, 2008
Posts: 139
You can write a servlet context listener. Hope the below link might help you.

“Any fool can write code that a computer can understand. Good programmers write code that humans can understand. ”<br>
-Martin Fowler
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16019

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,

Customer surveys are for companies who didn't pay proper attention to begin with.
It is sorta covered in the JavaRanch Style Guide.
subject: Initialization during application start-up