I've found it out! So simply and It wasnot clear to me!

I'm sorry for this question, since it is so easy:

When You specify additional resources, such
<message-resources key="identifier" parameter="sources.file" />

so You can sipmly access whole MessageResources class by for example in JSP:
<bean:define id="addtionalMessages" name="identifier"
type="org.apache.struts.util.MessageResources"/>

So the key to access the whole class equals (is the same) as the bundle key!
Simply.

Sorry for my stupid questions...

Best Regards
Honza Spurny


Honza Spurný wrote:
> Hi there,
>
> since I've been searching for answer for hours and nothing have
> found, I'd like to ask You for help.
>
> I'd like to define 2 (or more) MessageResources files (two differents
> bundles) by inserting into struts-config.xml this:
>
> <message-resources
> parameter="cz.master.is.sources.ApplicationResources" />
> <message-resources key="countries"
> parameter="cz.master.is.sources.Countries" />
>
> It's easy to access these message resources in jsp files. Since the
> first entry is stored under default key it can be accessed for
> example this way:
>
> <bean:message locale="locale" key="some.key" />
>
> and the second entry is accessible under specified key this way:
>
> <bean:message bundle="countries" locale="locale"
> key="country.usa.label" />
>
> This works fine. But sometimes I need to access MessageResources
> files in java classes. When I would like to access defualt messages
> object, I usually use this sequence:
>
> let's say request object is known...
> Locale locale = (Locale)request.getSession().getAttribute("locale");
> MessageResources messages =
> ((MessageResources)request.getAttribute(Globals.MESSAGES_KEY));
>
> This still works fine. I have problem (exactly said, I don't know how
> to) to access "countries" MessageResources. I have no idea how to
> access this additional Resources in java class. I've found out how to
> access them in the Action class:
>
> MessageResources countries = getResources(request, "countries");
>
> or
>
> MessageResources countries =
> (MessageResources)getServlet().getContext().getAttribute("countries");
>
> Please any idea how to do it?
>
> -----
>
> And the next question is how to do it in JSP files different way.
> Sometimes I use this in JSP files:
>
> <bean:define id="messages" name="<%=
> org.apache.struts.Globals.MESSAGES_KEY %>"
> type="org.apache.struts.util.MessageResources"/>
>
> what makes me able to access default MessegeResources as class in the
> JSP pages. Sometimes it's quite usefull for me. And according to
> this, I'd like to access the same way also my additional "Countries"
> MessageResources. But I don't know how to specify the bundle in the
> bean:define tag. I think there can be bundle specified only by name
> attribute. The way how to specify the bundle is probably the same, as
> above, but I have to enter there different value, that points on my
> additional resources. So where to find this value? If I would know
> this value, it could also help in the first question, that is above.
>
> ----
>
> Thanks for Your hints.
> I hope You know some tricks, I don't, and that will help.
>
> Thanks for help
>
> Best Regards
> Have a nice rest of day
>
> Honza Spurny
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]


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

Reply via email to