Hi Rickard

Not having until now i18n in ValidationEditorSupport breaks up the concept
of be able to use all validation methods available in webwork.

What I did to get the (rudimentary) possibility to handle localized error
messages with the ValidationEditorSupport was this:

I've extended ValidationEditorSupport in the following manner (borrowing a
lot from ActionSupport):

public abstract class LocalizedValidationEditorSupport extends
ValidationEditorSupport
{
    /**
     * returns the current locale
     */
    protected Locale getLocale()
    {
        return (Locale)
ActionContext.getContext().getSession().get("locale");
    }

    /**
     * Returns the base (MyActionBase) ResourceBundle
     */
    protected ResourceBundle getTexts()
    {
        return ResourceBundle.getBundle(MyActionBase.class.getName(),
            getLocale(), Thread.currentThread().getContextClassLoader());
    }


    /**
     * Returns the i18n string
     */
    protected String getText(String aTextName)
    {
        MissingResourceException e;

        try
        {
            ResourceBundle bundle = getTexts();

            return bundle.getString(aTextName);
        }
        catch (MissingResourceException ex)
        {
            e = ex;
        }

        throw e;
    }
}

Now I'm able to put all error messages in the MyActionBase_LOCALE.properties
file.
But as you can see it is 'hardcoded' and that's not is not the best way to
achieve  the exact same behaviour as we have with ActionSupport. Do you see
a better way to ingterate this in a more generalistic/proper way?

Thanks
-Paolo


> -----Ursprüngliche Nachricht-----
> Von: Rickard [mailto:[EMAIL PROTECTED]]
> Gesendet: Dienstag, 2. April 2002 14:24
> An: Vedovato Paolo
> Cc: Webwork-User (E-Mail)
> Betreff: Re: [Webwork-user] Access the ResourceBundles in
> ValidationEditorSupport subclasses
> 
> 
> Vedovato Paolo wrote:
> 
> > What is the best way to access the ResourceBundles which are 
> > setup for the views and actions when using ValidationEditors 
> > to be able to return localized error messages?
> 
> 
> I don't know of a good way, if you're talking about using 
> java.bean.PropertyEditor's.
> 
> /Rickard
> 
> -- 
> Rickard Öberg
> 
> 

_______________________________________________
Webwork-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webwork-user

Reply via email to