You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Barbara Post <ba...@ifrance.com> on 2002/06/10 13:41:18 UTC

default locale and unspecified locale (ActionForm)

Hello, I want to display back messages on my jsp after treatment by an
ActionForm. I use the classical method but want it to be localized.

However, I don't find how I can use my default .properties file if the
user's locale doesn't match the either default or known (not on the first
jsp though, it will be used for next jsps) locale.

I mean I have the following code in my ActionForm, and my .properties files
which contains localized msgs are : ApplicationResources.properties,
ApplicationResources_fr_FR.properties,
ApplicationResources_en_US.properties. I know that ..._fr_FR.properties can
be read because this is the default Locale on my computer.

ActionForm code (AuthenticationForm.class) :
..............
        private static Locale loc = Locale.getDefault();
................
resources = this.getServlet().getResources();
...........
ActionErrors errors = new ActionErrors();
        // get the fields on the form
        try{
        userCompany =
request.getParameterValues("company")[0].toUpperCase();
        userLogin = request.getParameterValues("login")[0];
        userPassword = request.getParameterValues("password")[0];
       // here I get the language
         userLang = request.getParameterValues("lang")[0];
        }
        catch(java.lang.NullPointerException e){
        // don't do anything
        }
        // fill an ActionErrors object
        if (userLogin == null || userLogin.length() < 1){
        try{
        errors.add("userLogin", new ActionError(resources.getMessage(loc,
"username.missing.field")));
        }
        catch(java.lang.NullPointerException np){
// here I want to use the "Localeless" msgs....
// or maybe I have to set locale to en_US ? Well, I'd prefer not to have  a
suffix but maybe I ask too much out of it ?
        errors.add("userLogin", new ActionError(resources.getMessage([what
to fill in here ??], "username.missing.field")));
        }
            // the same for the otheer fields
..............
}
        return(errors);



Barbara

 
______________________________________________________________________________
ifrance.com, l'email gratuit le plus complet de l'Internet !
vos emails depuis un navigateur, en POP3, sur Minitel, sur le WAP...
http://www.ifrance.com/_reloc/email.emailif



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>