You can do the same with an application scope bean using spring . Create a simple pojo that initializes values on the constructor. Then add an entry to the applicationContext.xml file :

<beans>
   <bean id="myComp" class="org.components.MyComponent" singleton="true"/>
</beans>

Then in your java action file that you wish to have access declare :

private MyComponent myComp;

and create a setter :

   public void setMyComp(MyComponent myComp) {
       this.myComp = myComp;
   }

Now you can get and edit these "default" values from your action.

I do not know if this is the best way to do it and please excuse if i have any typing mistake (it should be fine though...).

Regards,

Leon

Chris Pratt wrote:
On 9/7/07, j alex <[EMAIL PROTECTED]> wrote:
How is the ServletContextListener suited for my purpose ? . Can you please
elaborate a little more? . What i'm looking for is access to the properties
files' values and flags read from DB, not able to relate how this is related
to the listener.

In Struts 1, we were having an init servlet to load the application-wide
properties like dropdown values (from property files) into application
context and accessing these within JSP. Is there a better way of doing
this in Struts 2, and do we require an initialization servlet at all ? .

The ServletContextListener is called when the ServletContext is
starting up and shutting down.  It's designed to let you do one time
configuration and initialization.  You have access to the
ServletContext so that you can put things in the Application scope.
Sorry, I thought that's what you were asking for.
  (*Chris*)

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Reply via email to