You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by JOSE L MARTINEZ-AVIAL <jl...@gmail.com> on 2011/07/20 17:15:58 UTC

Access to Resource Bundle when there is no action

Hi,
  I'm using Struts 2.1.8.1, and I'm having some problems with accessing a
Resource bundle on an action that has no action class associated. It just
doesn't find the bundle, which seams reasonable since Struts doesn't know
where to look. I see that it's possible to define a global resources(
http://struts.apache.org/2.1.8/docs/localization.html), but I was wondering
if it is possible to define a 'default' bundle at a Struts package level. It
would be something like this:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
        "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
        "http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>

    <package name="stmts-doc" namespace="/doc" extends="stmts-default">
        <default-bundle name="com.stmts.doc.my-package.properties"/>

        <action name="SeeSelections">
            <interceptor-ref name="stmtsStack">
                <param
name="AuthoritationInterceptor.resource">SecurityMaster</param>
            </interceptor-ref>
            <result type="tiles">stmts.doc.selections.screen</result>
        </action>

    </package>

</struts>

Is it possible to do that?

TIA

Jose Luis

Re: Access to Resource Bundle when there is no action

Posted by Jeffrey Black <je...@yahoo.com>.
Hey Jose.  I did see you mention globalmessages in your first email but I missed your point.  My bad.

To Chris' point, the specification of multiple bundles via struts.properties would do the trick.

jb
/


On Jul 21, 2011, at 8:50 PM, JOSE L MARTINEZ-AVIAL <jl...@gmail.com> wrote:

> Hi Jeff,
>  Yes, that works(I think I mentioned it on my first mail). But my point is
> that it's only possible to setup that property at a global level, i.e., is
> the same property for all packages. Is it not possible to define that
> property at a package level? then I could have a package called "store" and
> other called "documents", and both of them could have a different definition
> of struts.custom.i18n.resource.
> 
> Regards
> 
> JL
> 
> 2011/7/21 Jeff Black <je...@yahoo.com>
> 
>> Hi Jose,
>> 
>> I have the following entry in my struts.properties file:
>> 
>>    struts.custom.i18n.resources=globalmessages
>> 
>> My globalmessage.properties file is sitting alongside my struts.properties
>> file
>> on the Classpath.
>> 
>> I am using, for example, <s:text/> tags to hit the resource bundle via my
>> Class-less JSP's.  I am using version 2.2.3.
>> 
>> Let us know if this helps.
>> 
>> Best,
>> 
>> jb
>> /
>> 
>> 
>> ________________________________
>> From: JOSE L MARTINEZ-AVIAL <jl...@gmail.com>
>> To: Struts Users Mailing List <us...@struts.apache.org>
>> Sent: Thu, July 21, 2011 8:16:35 AM
>> Subject: Re: Access to Resource Bundle when there is no action
>> 
>> Just to clarify that when I talk about "accessing a Resource bundle on an
>> action that has no action class" I mean accessing the resource from a JSP
>> called as as result from an Struts2 action that has no class associated.
>> Nobody has found this issue before? If so, how do you solve it?
>> 
>> TIA
>> 
>> Jose
>> 
>> 2011/7/20 JOSE L MARTINEZ-AVIAL <jl...@gmail.com>
>> 
>>> Hi,
>>> I'm using Struts 2.1.8.1, and I'm having some problems with accessing a
>>> Resource bundle on an action that has no action class associated. It just
>>> doesn't find the bundle, which seams reasonable since Struts doesn't know
>>> where to look. I see that it's possible to define a global resources(
>>> http://struts.apache.org/2.1.8/docs/localization.html), but I was
>>> wondering if it is possible to define a 'default' bundle at a Struts
>> package
>>> level. It would be something like this:
>>> 
>>> <?xml version="1.0" encoding="UTF-8" ?>
>>> <!DOCTYPE struts PUBLIC
>>>       "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
>>>       "http://struts.apache.org/dtds/struts-2.0.dtd">
>>> 
>>> <struts>
>>> 
>>>   <package name="stmts-doc" namespace="/doc" extends="stmts-default">
>>>       <default-bundle name="com.stmts.doc.my-package.properties"/>
>>> 
>>>       <action name="SeeSelections">
>>>           <interceptor-ref name="stmtsStack">
>>>               <param
>>> name="AuthoritationInterceptor.resource">SecurityMaster</param>
>>>           </interceptor-ref>
>>>           <result type="tiles">stmts.doc.selections.screen</result>
>>>       </action>
>>> 
>>>   </package>
>>> 
>>> </struts>
>>> 
>>> Is it possible to do that?
>>> 
>>> TIA
>>> 
>>> Jose Luis
>>> 
>> 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Access to Resource Bundle when there is no action

Posted by JOSE L MARTINEZ-AVIAL <jl...@gmail.com>.
Humm, I didn't know I could setup multiple values for that. Will try. Any
case, I think that declaring a default resource per package could be useful,
so maybe I will fill a Jira to request that.


Thanks for your help.

JL

2011/7/22 Chris Pratt <th...@gmail.com>

> It may not be a perfect solution, but you can specify multiple values for
> that property.  Maybe something like this would work:
>
> struts.custom.i18n.resources=store, documents
>
> or even:
>
> struts.custom.i18n.resources=com.package.store, com.package.documents
>
> Which would allow you to have a com/package/store.properties on the
> classpath, and a com/package/documents.properties as well.  They're both
> technically global, but as long as you treat them as package specific, they
> will behave fine.
>  (*Chris*)
>
> On Thu, Jul 21, 2011 at 6:50 PM, JOSE L MARTINEZ-AVIAL <jlmagc@gmail.com
> >wrote:
>
> > Hi Jeff,
> >  Yes, that works(I think I mentioned it on my first mail). But my point
> is
> > that it's only possible to setup that property at a global level, i.e.,
> is
> > the same property for all packages. Is it not possible to define that
> > property at a package level? then I could have a package called "store"
> and
> > other called "documents", and both of them could have a different
> > definition
> > of struts.custom.i18n.resource.
> >
> > Regards
> >
> > JL
> >
> > 2011/7/21 Jeff Black <je...@yahoo.com>
> >
> > > Hi Jose,
> > >
> > > I have the following entry in my struts.properties file:
> > >
> > >     struts.custom.i18n.resources=globalmessages
> > >
> > > My globalmessage.properties file is sitting alongside my
> > struts.properties
> > > file
> > > on the Classpath.
> > >
> > > I am using, for example, <s:text/> tags to hit the resource bundle via
> my
> > > Class-less JSP's.  I am using version 2.2.3.
> > >
> > > Let us know if this helps.
> > >
> > > Best,
> > >
> > > jb
> > > /
> > >
> > >
> > > ________________________________
> > > From: JOSE L MARTINEZ-AVIAL <jl...@gmail.com>
> > > To: Struts Users Mailing List <us...@struts.apache.org>
> > > Sent: Thu, July 21, 2011 8:16:35 AM
> > > Subject: Re: Access to Resource Bundle when there is no action
> > >
> > > Just to clarify that when I talk about "accessing a Resource bundle on
> an
> > > action that has no action class" I mean accessing the resource from a
> JSP
> > > called as as result from an Struts2 action that has no class
> associated.
> > > Nobody has found this issue before? If so, how do you solve it?
> > >
> > > TIA
> > >
> > > Jose
> > >
> > > 2011/7/20 JOSE L MARTINEZ-AVIAL <jl...@gmail.com>
> > >
> > > > Hi,
> > > >  I'm using Struts 2.1.8.1, and I'm having some problems with
> accessing
> > a
> > > > Resource bundle on an action that has no action class associated. It
> > just
> > > > doesn't find the bundle, which seams reasonable since Struts doesn't
> > know
> > > > where to look. I see that it's possible to define a global resources(
> > > > http://struts.apache.org/2.1.8/docs/localization.html), but I was
> > > > wondering if it is possible to define a 'default' bundle at a Struts
> > > package
> > > > level. It would be something like this:
> > > >
> > > > <?xml version="1.0" encoding="UTF-8" ?>
> > > > <!DOCTYPE struts PUBLIC
> > > >        "-//Apache Software Foundation//DTD Struts Configuration
> > 2.0//EN"
> > > >        "http://struts.apache.org/dtds/struts-2.0.dtd">
> > > >
> > > > <struts>
> > > >
> > > >    <package name="stmts-doc" namespace="/doc"
> extends="stmts-default">
> > > >        <default-bundle name="com.stmts.doc.my-package.properties"/>
> > > >
> > > >        <action name="SeeSelections">
> > > >            <interceptor-ref name="stmtsStack">
> > > >                <param
> > > > name="AuthoritationInterceptor.resource">SecurityMaster</param>
> > > >            </interceptor-ref>
> > > >            <result type="tiles">stmts.doc.selections.screen</result>
> > > >        </action>
> > > >
> > > >    </package>
> > > >
> > > > </struts>
> > > >
> > > > Is it possible to do that?
> > > >
> > > > TIA
> > > >
> > > > Jose Luis
> > > >
> > >
> >
>

Re: Access to Resource Bundle when there is no action

Posted by Chris Pratt <th...@gmail.com>.
It may not be a perfect solution, but you can specify multiple values for
that property.  Maybe something like this would work:

struts.custom.i18n.resources=store, documents

or even:

struts.custom.i18n.resources=com.package.store, com.package.documents

Which would allow you to have a com/package/store.properties on the
classpath, and a com/package/documents.properties as well.  They're both
technically global, but as long as you treat them as package specific, they
will behave fine.
  (*Chris*)

On Thu, Jul 21, 2011 at 6:50 PM, JOSE L MARTINEZ-AVIAL <jl...@gmail.com>wrote:

> Hi Jeff,
>  Yes, that works(I think I mentioned it on my first mail). But my point is
> that it's only possible to setup that property at a global level, i.e., is
> the same property for all packages. Is it not possible to define that
> property at a package level? then I could have a package called "store" and
> other called "documents", and both of them could have a different
> definition
> of struts.custom.i18n.resource.
>
> Regards
>
> JL
>
> 2011/7/21 Jeff Black <je...@yahoo.com>
>
> > Hi Jose,
> >
> > I have the following entry in my struts.properties file:
> >
> >     struts.custom.i18n.resources=globalmessages
> >
> > My globalmessage.properties file is sitting alongside my
> struts.properties
> > file
> > on the Classpath.
> >
> > I am using, for example, <s:text/> tags to hit the resource bundle via my
> > Class-less JSP's.  I am using version 2.2.3.
> >
> > Let us know if this helps.
> >
> > Best,
> >
> > jb
> > /
> >
> >
> > ________________________________
> > From: JOSE L MARTINEZ-AVIAL <jl...@gmail.com>
> > To: Struts Users Mailing List <us...@struts.apache.org>
> > Sent: Thu, July 21, 2011 8:16:35 AM
> > Subject: Re: Access to Resource Bundle when there is no action
> >
> > Just to clarify that when I talk about "accessing a Resource bundle on an
> > action that has no action class" I mean accessing the resource from a JSP
> > called as as result from an Struts2 action that has no class associated.
> > Nobody has found this issue before? If so, how do you solve it?
> >
> > TIA
> >
> > Jose
> >
> > 2011/7/20 JOSE L MARTINEZ-AVIAL <jl...@gmail.com>
> >
> > > Hi,
> > >  I'm using Struts 2.1.8.1, and I'm having some problems with accessing
> a
> > > Resource bundle on an action that has no action class associated. It
> just
> > > doesn't find the bundle, which seams reasonable since Struts doesn't
> know
> > > where to look. I see that it's possible to define a global resources(
> > > http://struts.apache.org/2.1.8/docs/localization.html), but I was
> > > wondering if it is possible to define a 'default' bundle at a Struts
> > package
> > > level. It would be something like this:
> > >
> > > <?xml version="1.0" encoding="UTF-8" ?>
> > > <!DOCTYPE struts PUBLIC
> > >        "-//Apache Software Foundation//DTD Struts Configuration
> 2.0//EN"
> > >        "http://struts.apache.org/dtds/struts-2.0.dtd">
> > >
> > > <struts>
> > >
> > >    <package name="stmts-doc" namespace="/doc" extends="stmts-default">
> > >        <default-bundle name="com.stmts.doc.my-package.properties"/>
> > >
> > >        <action name="SeeSelections">
> > >            <interceptor-ref name="stmtsStack">
> > >                <param
> > > name="AuthoritationInterceptor.resource">SecurityMaster</param>
> > >            </interceptor-ref>
> > >            <result type="tiles">stmts.doc.selections.screen</result>
> > >        </action>
> > >
> > >    </package>
> > >
> > > </struts>
> > >
> > > Is it possible to do that?
> > >
> > > TIA
> > >
> > > Jose Luis
> > >
> >
>

Re: Access to Resource Bundle when there is no action

Posted by JOSE L MARTINEZ-AVIAL <jl...@gmail.com>.
Hi Jeff,
  Yes, that works(I think I mentioned it on my first mail). But my point is
that it's only possible to setup that property at a global level, i.e., is
the same property for all packages. Is it not possible to define that
property at a package level? then I could have a package called "store" and
other called "documents", and both of them could have a different definition
of struts.custom.i18n.resource.

Regards

JL

2011/7/21 Jeff Black <je...@yahoo.com>

> Hi Jose,
>
> I have the following entry in my struts.properties file:
>
>     struts.custom.i18n.resources=globalmessages
>
> My globalmessage.properties file is sitting alongside my struts.properties
> file
> on the Classpath.
>
> I am using, for example, <s:text/> tags to hit the resource bundle via my
> Class-less JSP's.  I am using version 2.2.3.
>
> Let us know if this helps.
>
> Best,
>
> jb
> /
>
>
> ________________________________
> From: JOSE L MARTINEZ-AVIAL <jl...@gmail.com>
> To: Struts Users Mailing List <us...@struts.apache.org>
> Sent: Thu, July 21, 2011 8:16:35 AM
> Subject: Re: Access to Resource Bundle when there is no action
>
> Just to clarify that when I talk about "accessing a Resource bundle on an
> action that has no action class" I mean accessing the resource from a JSP
> called as as result from an Struts2 action that has no class associated.
> Nobody has found this issue before? If so, how do you solve it?
>
> TIA
>
> Jose
>
> 2011/7/20 JOSE L MARTINEZ-AVIAL <jl...@gmail.com>
>
> > Hi,
> >  I'm using Struts 2.1.8.1, and I'm having some problems with accessing a
> > Resource bundle on an action that has no action class associated. It just
> > doesn't find the bundle, which seams reasonable since Struts doesn't know
> > where to look. I see that it's possible to define a global resources(
> > http://struts.apache.org/2.1.8/docs/localization.html), but I was
> > wondering if it is possible to define a 'default' bundle at a Struts
> package
> > level. It would be something like this:
> >
> > <?xml version="1.0" encoding="UTF-8" ?>
> > <!DOCTYPE struts PUBLIC
> >        "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
> >        "http://struts.apache.org/dtds/struts-2.0.dtd">
> >
> > <struts>
> >
> >    <package name="stmts-doc" namespace="/doc" extends="stmts-default">
> >        <default-bundle name="com.stmts.doc.my-package.properties"/>
> >
> >        <action name="SeeSelections">
> >            <interceptor-ref name="stmtsStack">
> >                <param
> > name="AuthoritationInterceptor.resource">SecurityMaster</param>
> >            </interceptor-ref>
> >            <result type="tiles">stmts.doc.selections.screen</result>
> >        </action>
> >
> >    </package>
> >
> > </struts>
> >
> > Is it possible to do that?
> >
> > TIA
> >
> > Jose Luis
> >
>

Re: Access to Resource Bundle when there is no action

Posted by Jeff Black <je...@yahoo.com>.
Hi Jose,

I have the following entry in my struts.properties file:

    struts.custom.i18n.resources=globalmessages

My globalmessage.properties file is sitting alongside my struts.properties file 
on the Classpath.

I am using, for example, <s:text/> tags to hit the resource bundle via my 
Class-less JSP's.  I am using version 2.2.3.

Let us know if this helps.

Best,

jb
/


________________________________
From: JOSE L MARTINEZ-AVIAL <jl...@gmail.com>
To: Struts Users Mailing List <us...@struts.apache.org>
Sent: Thu, July 21, 2011 8:16:35 AM
Subject: Re: Access to Resource Bundle when there is no action

Just to clarify that when I talk about "accessing a Resource bundle on an
action that has no action class" I mean accessing the resource from a JSP
called as as result from an Struts2 action that has no class associated.
Nobody has found this issue before? If so, how do you solve it?

TIA

Jose

2011/7/20 JOSE L MARTINEZ-AVIAL <jl...@gmail.com>

> Hi,
>  I'm using Struts 2.1.8.1, and I'm having some problems with accessing a
> Resource bundle on an action that has no action class associated. It just
> doesn't find the bundle, which seams reasonable since Struts doesn't know
> where to look. I see that it's possible to define a global resources(
> http://struts.apache.org/2.1.8/docs/localization.html), but I was
> wondering if it is possible to define a 'default' bundle at a Struts package
> level. It would be something like this:
>
> <?xml version="1.0" encoding="UTF-8" ?>
> <!DOCTYPE struts PUBLIC
>        "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
>        "http://struts.apache.org/dtds/struts-2.0.dtd">
>
> <struts>
>
>    <package name="stmts-doc" namespace="/doc" extends="stmts-default">
>        <default-bundle name="com.stmts.doc.my-package.properties"/>
>
>        <action name="SeeSelections">
>            <interceptor-ref name="stmtsStack">
>                <param
> name="AuthoritationInterceptor.resource">SecurityMaster</param>
>            </interceptor-ref>
>            <result type="tiles">stmts.doc.selections.screen</result>
>        </action>
>
>    </package>
>
> </struts>
>
> Is it possible to do that?
>
> TIA
>
> Jose Luis
>

Re: Access to Resource Bundle when there is no action

Posted by JOSE L MARTINEZ-AVIAL <jl...@gmail.com>.
Just to clarify that when I talk about "accessing a Resource bundle on an
action that has no action class" I mean accessing the resource from a JSP
called as as result from an Struts2 action that has no class associated.
Nobody has found this issue before? If so, how do you solve it?

TIA

Jose

2011/7/20 JOSE L MARTINEZ-AVIAL <jl...@gmail.com>

> Hi,
>   I'm using Struts 2.1.8.1, and I'm having some problems with accessing a
> Resource bundle on an action that has no action class associated. It just
> doesn't find the bundle, which seams reasonable since Struts doesn't know
> where to look. I see that it's possible to define a global resources(
> http://struts.apache.org/2.1.8/docs/localization.html), but I was
> wondering if it is possible to define a 'default' bundle at a Struts package
> level. It would be something like this:
>
> <?xml version="1.0" encoding="UTF-8" ?>
> <!DOCTYPE struts PUBLIC
>         "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
>         "http://struts.apache.org/dtds/struts-2.0.dtd">
>
> <struts>
>
>     <package name="stmts-doc" namespace="/doc" extends="stmts-default">
>         <default-bundle name="com.stmts.doc.my-package.properties"/>
>
>         <action name="SeeSelections">
>             <interceptor-ref name="stmtsStack">
>                 <param
> name="AuthoritationInterceptor.resource">SecurityMaster</param>
>             </interceptor-ref>
>             <result type="tiles">stmts.doc.selections.screen</result>
>         </action>
>
>     </package>
>
> </struts>
>
> Is it possible to do that?
>
> TIA
>
> Jose Luis
>