Hi Volker,

yes, I'm sure it must be a little stupid mistake, but can't find out.
The key is defined in package_en.properties and recompiling the classes has
the same result.

perhaps you have a look to my code.

package_en.properties:
...
error.login.failed=Invalid username or password. Please try again.
...

Logon.jsp:
...
<s:actionerror/>
<div>
<s:form cssClass="left" method="POST" validate="true" action="doLogon"> 
        <s:textfield key="username" />
        <s:password key="password" />
        <s:hidden name="request_locale" value="en" />
    <s:submit key="button.login"/>
</s:form>
</div>
...
<div>
  <s:url id="en" action="Welcome">
  <s:param name="request_locale">en</s:param>
  </s:url>
  <s:a href="%{en}">English</s:a>
  </li>
  <li>
  <s:url id="de" action="Welcome">
  <s:param name="request_locale">de</s:param>
  </s:url>
  <s:a href="%{de}">Deutsch</s:a>
  </li>

Logon.java:

public class Logon extends MYActionSupport (<-- MyActionSupport implements
ServletRequestAware) {

        /**
         * 
         */
        private static final long serialVersionUID = 1L;
        
        private String password;
        private String username;
        
        @Override
        protected String checkLogin() {
                if (isInvalid(getUsername()) || isInvalid(getPassword())) {
                        return ERROR;
                } else {
                        return loadUser();
                }
        }
        
        private boolean isInvalid(String value) {
                return value == null || value.trim().equals("");
        }

        public String getUsername() {
                return username;
        }

        public void setUsername(String username) {
                this.username = username;
        }

        public String getPassword() {
                return password;
        }

        public void setPassword(String password) {
                this.password = password;
        }

        protected String loadUser() {   
                
                HashMap<String, String> loginParams = new HashMap<String, 
String>();
                loginParams.put("login", username != null ? username : "");
                loginParams.put("password", password != null ? password : "");
                
                try{
                Customer customer = (Customer)UserUtility.loadUser(loginParams,
UserUtility.CUSTOMER, getServletContext().getRealPath("/"));
                        
                if (customer != null) {
                        customer.setLoggedIn(true);                     
                        getSession().put("user", customer);
                        return SUCCESS;
                }
                } catch (Exception sql) {
                        addActionError(getText("error.login.failed"));
                        return ERROR;
                }

                addActionError(getText("error.login.failed"));
                return LOGIN;
        }
}


Do I have to configure the requestParameter request_locale in any case?
I just follow the tutorials since here.

Any idea?



Volker Karlmeier wrote:
> 
> Hi Stan,
> 
> mostly it's just a little mistake, that makes you crazy ....
> Did you make sure that the key in the properties_en-file is existent and
> properly written (error.login.failed) ?
> I am using the same mechanism an it works without any trouble. Can only be
> a stupid mistake. 
> If you are using eclipse, try to find out if your java-classes are
> compiled. (Just delete the .class file and compile).
> Had that problem yesterday. (Just an idea ;)   )
> 
> 
> 
> Hi Volker,
> 
> my Action class implements ServletRequestAware. When I check the locale
> with
> request.getParameter("request_locale"), I get 'en' as result.
> 
> The both *.properties files are in the same classpath. 
> If the logon is invalid I put the actionError and return LOGIN
> and go back to Logon.jsp.
> 
> My action definition: 
> <action name="doLogon" class="com.imp.app.usr.Logon">
> <result name="input">/Logon.jsp</result>
> <result name="error">/Logon.jsp</result>
> <result name="login">/Logon.jsp</result>      
> <result name="success" type="redirect-action">
> Welcome
> </result>                             
> </action>
> 
> After the action, the Logon.jsp is displayed with all contents in english
> excepting the action Error and the hole login form,
> including labels, buttons etc. wich seems to get his content from
> package.properties.
> 
> All menu items, another form and anything else is displayed from the
> package_en.properties.
> I don't why, because both files are at the same position.
> 
> 
> 
> 
> Volker Karlmeier wrote:
>> 
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>  
>> Hi,
>> 
>>     you should try to find out, what the acutal locale is and if there
>> is a suitable properties-file.
>>     Next, try to find out, if your properties-file is found in the
>> right position. (Package etc.) and if it
>>     is accessible.
>>     Maybe you have not extended RequestAware in your class.....
>> 
>> 
>> Volker
>> 
>> stan77 schrieb:
>>> Hello,
>>>
>>> I'm new to struts 2.
>>> I have the following problem with internationalization in my Action
>> classes.
>>>
>>> there are two properties files package.properties and
>>> package_en.properties
>>> wich works correctly in most cases.
>>>
>>> In my Logon action i would like to add an Action error like this:
>>>
>>> addActionError(getText("error.login.failed"));
>>>
>>> The message is dispayed in my jsp, but always get it's string from
>>> package.properties,
>>> never from package_en.properties. Seems, that the request_locale is not
>>> reachable in my
>>> Action class.
>>> I've searched a several days for a solution, but can't find anything.
>>>
>>> Thanks for help.
>> 
>> -----BEGIN PGP SIGNATURE-----
>> Version: GnuPG v1.4.3 (MingW32)
>> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>>  
>> iD8DBQFICzpUx4KjH6Tk4MMRApIbAKC4pKdtpGstmMYb5F7mr/SU2AdHqgCfRtQR
>> UKbnP14prumG73NvVAQBy7w=
>> =2ETC
>> -----END PGP SIGNATURE-----
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>> 
>> 
>> 
> 
> -- 
> View this message in context: 
> http://www.nabble.com/Problem-with-internationalization-in-addActionError-tp1679
> 0683p16797626.html
> Sent from the Struts - User mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> 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]
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Problem-with-internationalization-in-addActionError-tp16790683p16806471.html
Sent from the Struts - User mailing list archive at Nabble.com.


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

Reply via email to