Yup, right here:
/**
* Get the locale that will be used for a conversion operation.
*/
protected Locale getLocale(HttpServletRequest request) {
Locale locale = null;
// see if there's a locale present among the session attributes
HttpSession session = request.getSession(false);
if (session != null) {
locale = (Locale) session.getAttribute(Globals.LOCALE_KEY);
}
// if we can't find anything in the session,
// use the one which request provides
if (locale == null) {
locale = request.getLocale();
}
return locale;
}
Lemme know if you need more. Sorry, don't have time to double check
everything right now. I'm getting these from:
https://formdef.dev.java.net/source/browse/formdef/src/java/formdef/plugin/util/FormUtils.java?rev=1.8&content-type=text/vnd.viewcvs-markup
:p
On Wed, 13 Oct 2004 15:42:22 +0000 (UTC), Alan Pocklington
<[EMAIL PROTECTED]> wrote:
> In that case, do you have the existing code for the method
> getLocale(request)? I haven't got my head around locales yet.
>
>
> Hubert Rabago <[EMAIL PROTECTED]> wrote in
> news:[EMAIL PROTECTED]:
>
>
>
> > Yup, copy/paste from existing code works fast. :)
> >
> >
> > On Wed, 13 Oct 2004 15:35:24 +0000 (UTC), Alan Pocklington
> > <[EMAIL PROTECTED]> wrote:
> >> Wow, thanks for the quick reply. Will do!
> >>
> >> Hubert Rabago <[EMAIL PROTECTED]> wrote in
> >> news:[EMAIL PROTECTED]:
> >>
> >>
> >>
> >> > Put this in a util class and call evaluateMessage():
> >> >
> >> > /**
> >> > * <p>Evaluate the given message resource key.</p>
> >> > *
> >> > * @param messageKey the name of the resource entry to retrieve
> >> > * @param bundle The key specified in the
> >> > * <code><message-resources></code> element for the
> >> > * resource bundle to use
> >> > * @param request the request being processed
> >> > * @param servletContext the current [EMAIL PROTECTED] ServletContext}
> >> > * @return the value of paramName from the message resources
> >> > */
> >> > public String evaluateMessage(
> >> > String messageKey,
> >> > String bundle,
> >> > HttpServletRequest request,
> >> > ServletContext servletContext) {
> >> > // get the message resources
> >> > MessageResources resources;
> >> > if (bundle != null) {
> >> > resources = getResources(bundle, request,
> >> > servletContext);
> >> > } else {
> >> > resources = getResources(request);
> >> > }
> >> > // evaluate the message
> >> > String messageString = getMessage(messageKey, null,
> >> > request,
> >> > resources);
> >> >
> >> > // add it to the redirect parameters
> >> > if ((messageString != null) && (messageString.length() >
> >> > 0)) {
> >> > return messageString;
> >> > }
> >> > return null;
> >> > }
> >> >
> >> >
> >> > /**
> >> > * <p>Look for the ActionMessage in the provided
> >> > MessageResources.</p> *
> >> > * @param messageKey the key to look for
> >> > * @param args the arguments to be used in evaluating the
> >> > message * @param request the request being processed
> >> > * @param resources the application's message resources
> >> > * @return the message formed from the given ActionMessage
> >> > */
> >> > protected String getMessage(String messageKey,
> >> > Object[] args,
> >> > HttpServletRequest request,
> >> > MessageResources resources) {
> >> > if (messageKey == null) {
> >> > //log.warn("Call to getMessage() with a null
> >> > messageKey."); return null;
> >> > }
> >> >
> >> > String result = null;
> >> > try {
> >> > // first, get the locale from the request
> >> > Locale userLocale = getLocale(request);
> >> >
> >> > // then, get the message
> >> > if (args == null) {
> >> > result = (resources.getMessage(userLocale,
> >> > messageKey));
> >> > } else {
> >> > result = (resources.getMessage(userLocale,
> >> > messageKey,
> >> > args));
> >> > }
> >> > } catch (Exception e) {
> >> > //log.error("Exception while looking for message.", e);
> >> > }
> >> > return result;
> >> > }
> >> >
> >> > /**
> >> > * <p>Return the default message resources for the current
> >> > module.</p> *
> >> > * @param request The servlet request we are processing
> >> > */
> >> > protected MessageResources getResources(HttpServletRequest
> >> > request) {
> >> >
> >> > return ((MessageResources)
> >> > request.getAttribute(Globals.MESSAGES_KEY));
> >> >
> >> > }
> >> >
> >> > /**
> >> > * <p>Return the specified message resources for the current
> >> > module.</p> *
> >> > * @param bundle The key specified in the
> >> > * <code><message-resources></code> element for the
> >> > * requested bundle
> >> > * @param request The servlet request we are processing
> >> > * @param servletContext the current [EMAIL PROTECTED] ServletContext}
> >> > */
> >> > protected MessageResources getResources(String bundle,
> >> > HttpServletRequest
> >> > request,
> >> > ServletContext
> >> > servletContext) {
> >> >
> >> > // Identify the current module
> >> > ModuleConfig moduleConfig =
> >> > ModuleUtils.getInstance().getModuleConfig(
> >> > request, servletContext);
> >> >
> >> > // Return the requested message resources instance
> >> > return ((MessageResources) servletContext.getAttribute
> >> > (bundle + moduleConfig.getPrefix()));
> >> >
> >> > }
> >> >
> >> >
> >> >
> >> > On Wed, 13 Oct 2004 15:24:27 +0000 (UTC), Alan Pocklington
> >> > <[EMAIL PROTECTED]> wrote:
> >> >> Hi,
> >> >>
> >> >> I want my action to read a property from the
> >> >> MessageResources.properties file in the same way that
> >> >> ActionMessages does. What's the simplest code I can use to
> >> >> retreive a particular property's value?
> >> >>
> >> >> Thanks in advance,
> >> >>
> >> >> -------------------------------------------------------------------
> >> >> -- 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]
> >>
> >>
> >
>
>
>
>
> ---------------------------------------------------------------------
> 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]