Sachin Bhutada wrote:
> hi Honza Spurný ,
>
> Try this out ..
>
> RequestUtils.message(pageContext,"countries","locale",
> "country.usa.label", null);
> It will return u the appropriate string. It may work.

Hi there,

thanks for hint. This should work, there's no problem probably in it. Only
think I can see on first view is, that this method is deprecated - this is
still not the biggest problem, but this will return only one message. What I
need more is to get whole MessageResources class.

But thanks for hint. This is usable in limited number of cases I need it to
use. (but it's a step forward for me :)

Honza S.

>
> sachin
> xoriant, mumbai
>
> -----Original Message-----
> From: Honza Spurný [mailto:[EMAIL PROTECTED]
> Sent: Friday, September 17, 2004 1:48 PM
> To: [EMAIL PROTECTED]
> Subject: Accesssing the multiple MessageResources
>
>
> 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