Hi!

I'm using struts-1.0.2. My question concerns the usage of the
MessageResource.
I've set my own application resource into session scope.
But now, I'd like that all my jsp pages search for resources into the
session scope instead of the application scope (so that each user can
configure which language he wants to use, instead of configuring the langage
in use for the whole application).
When using <bean:message key="language.in.used"> in a jsp page, the resource
will be search into the application scope.
Of course I've tried this command: <bean:message key="language.in.used"
scope="session">,
(my own resources are recorded into the session with the attribute
Actions.MESSAGES_KEY)
but it doesn't work. In fact, the code source code of struts doesn't let us
the choice:
In RequestUtils.java, you set the scope to APPLICATION
 /**
     * Look up and return a message string, based on the specified
parameters.
     *
     * @param pageContext The PageContext associated with this request
     * @param bundle Name of the servlet context attribute for our
     *  message resources bundle
     * @param locale Name of the session attribute for our user's Locale
     * @param key Message key to be looked up and returned
     * @param args Replacement parameters for this message
     *
     * @exception JspException if a lookup error occurs (will have been
     *  saved in the request already)
     */
    public static String message(PageContext pageContext, String bundle,
                                 String locale, String key, Object args[])
        throws JspException {

        // Look up the requested MessageResources
        if (bundle == null)
            bundle = Action.MESSAGES_KEY;
        MessageResources resources = (MessageResources)
            pageContext.getAttribute(bundle, PageContext.APPLICATION_SCOPE);
        if (resources == null) {
            JspException e = new JspException
                (messages.getMessage("message.bundle", bundle));
            saveException(pageContext, e);
            throw e;
        }

        // Look up the requested Locale
        if (locale == null)
            locale = Action.LOCALE_KEY;
        Locale userLocale = (Locale)
            pageContext.getAttribute(locale, PageContext.SESSION_SCOPE);
        if (userLocale == null)
            userLocale = defaultLocale;

        // Return the requested message
        if (args == null)
            return (resources.getMessage(userLocale, key));
        else
            return (resources.getMessage(userLocale, key, args));

    }

So my question is: does anyone has any idea to configure a MessageResource
for one HttpSession (session scope) and  not for all the ServletContext
(=application scope)?

Regards,
Christine

Christine Plumejeaud
SA Eloquant
06 17 08 45 97


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

Reply via email to