You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Buics <rb...@pc.ntep.nec.co.jp> on 2003/04/14 07:05:47 UTC
How to use ApplicationResources.properties in a JavaBean
I have a java bean called SampleBean.class
I have this code to access my EJB stuff
oEnv.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sybase.ejb.InitialContextFactory");
oEnv.put(Context.PROVIDER_URL, "server_url");
oEnv.put(javax.naming.Context.SECURITY_PRINCIPAL, "username");
oEnv.put(javax.naming.Context.SECURITY_CREDENTIALS, "password");
Is it possible to use the struts ApplicationResources.properties to make those
context properties dynamic?
or any suggestions may help.
TIA,
Buics
Re: How to use ApplicationResources.properties in a JavaBean
Posted by Buics <rb...@pc.ntep.nec.co.jp>.
Thank you Phil, I think this is best solution to implement.
--buics
Phil Steitz wrote:
> Buics wrote:
> > I have a java bean called SampleBean.class
> >
> > I have this code to access my EJB stuff
> >
> > oEnv.put(Context.INITIAL_CONTEXT_FACTORY,
> > "com.sybase.ejb.InitialContextFactory");
> > oEnv.put(Context.PROVIDER_URL, "server_url");
> > oEnv.put(javax.naming.Context.SECURITY_PRINCIPAL, "username");
> > oEnv.put(javax.naming.Context.SECURITY_CREDENTIALS, "password");
> >
> > Is it possible to use the struts ApplicationResources.properties to make those
> > context properties dynamic?
>
> You can use the MessageResources.getMessage() to retrieve the property
> values from ApplicationResources.properties at run time.
>
> For example, if you have
> initialContextFactory=com.sybase.ejb.InitialContextFactory
> in your ApplicationResources.properties, you can use
>
> MessageResources messages =
> MessageResources.getMessageResources("ApplicationResources");
> oEnv.put(Context.INITIAL_CONTEXT_FACTORY,
> messages.getMessage("initialContextFactory"));
>
> see
> http://jakarta.apache.org/struts/api/org/apache/struts/util/MessageResources.html
>
> >
> > or any suggestions may help.
> >
> > TIA,
> > Buics
> >
> >
> >
> > ------------------------------------------------------------------------
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: How to use ApplicationResources.properties in a JavaBean
Posted by Phil Steitz <ph...@steitz.com>.
Buics wrote:
> I have a java bean called SampleBean.class
>
> I have this code to access my EJB stuff
>
> oEnv.put(Context.INITIAL_CONTEXT_FACTORY,
> "com.sybase.ejb.InitialContextFactory");
> oEnv.put(Context.PROVIDER_URL, "server_url");
> oEnv.put(javax.naming.Context.SECURITY_PRINCIPAL, "username");
> oEnv.put(javax.naming.Context.SECURITY_CREDENTIALS, "password");
>
> Is it possible to use the struts ApplicationResources.properties to make those
> context properties dynamic?
You can use the MessageResources.getMessage() to retrieve the property
values from ApplicationResources.properties at run time.
For example, if you have
initialContextFactory=com.sybase.ejb.InitialContextFactory
in your ApplicationResources.properties, you can use
MessageResources messages =
MessageResources.getMessageResources("ApplicationResources");
oEnv.put(Context.INITIAL_CONTEXT_FACTORY,
messages.getMessage("initialContextFactory"));
see
http://jakarta.apache.org/struts/api/org/apache/struts/util/MessageResources.html
>
> or any suggestions may help.
>
> TIA,
> Buics
>
>
>
> ------------------------------------------------------------------------
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org