Hi there,

try this:

if (username == null || username.trim().length() == 0){
ActionMessages messages = new ActionMessages();
ActionMessage message = new ActionMessage("credentials.empty");

> messages.add(ActioneMessages.GLOBAL_ERROR, message);
> saveMessages(request,messages);


}

Basically, the thing to note here that ActionMessage takes a key from the
resource file which I assumed "credentails.empty" is. The first parameter of
the ActionMessges.add(...) is the property against which error is being
stored or the generic global_error constant.

HTH.

ATTA




On 9/27/05, Kaizar Amin <[EMAIL PROTECTED]> wrote:
>
> Hello all,
>
> I am facing a wierd problem in my application. I want to add an
> ActionMessage in the ACTION (LoginAction) class and then display the
> message in the JSP page. In the JSP page, the messages are found without a
> problem (so my ApplicationResources.properties configuration is fine),
> however while prinintg them, the string "???en_US" and "???" gets attached
> to my message before and after respectively.
>
> ???en_US.<my-message>???
>
> How do I get rid of these strings???
>
> I searched the discussion-list for similar problems/solutions and found
> this thread:
>
> http://www.mail-archive.com/user@struts.apache.org/msg27565.html
>
> However, the solution in that threads talks about using the presentation
> logic as follows:
>
> <html:messages id="errmsgs">
> <li><bean:write name="errmsgs"/></li>
> </html:messages>
>
> But thats exactly how I am doing also. But for me it still gives the
> error.
> Below is the configuration and code snippets that I am using:
>
> In struts-config,xml
> ====================
> <message-resources parameter="myApp.ApplicationResources" null="false"/>
>
>
> In LoginAction.java
> ====================
> if (username == null || username.trim().length() == 0){
> ActionMessages messages = new ActionMessages();
> ActionMessage message = new ActionMessage("Username/Password cannot
> be empty");
> messages.add("credentials.empty", message);
> saveMessages(request,messages);
>
> In the JSP page
> ====================
> <html:messages id="message" message="true">
> <div class="success">
> <bean:write name="message"/><br>
> </div><br/>
> </html:messages>
>
> The output I get is
> ====================
> ???en_US.Username/Password cannot be empty???
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

Reply via email to