You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Deepesh Nandal <de...@eth.net> on 2005/09/09 11:32:02 UTC

Generate ActionMessage object without referring to the resource file

Hi There,
  I need to generate an ActionMessage object without referring to the resource file, as the message is received from a different server on the fly.
 Following code works fine if i have "Login.invalid" defined in the resource property file.

ActionMessage message = new ActionMessage("Login.invalid");


But I need it so that the message could be a Java String object ,the Following code DOESN'T work :

String message = "I am a message" ;
ActionMessage message = new ActionMessage(message);

Please Help,

Many Thanks,
Deepesh.



Re: Generate ActionMessage object without referring to the resource file

Posted by Wendy Smoak <ja...@wendysmoak.com>.
From: "Deepesh Nandal" <de...@eth.net>

>  I need to generate an ActionMessage object without referring to the 
> resource file, as the message is received from a different server on the 
> fly.
>
> I need it so that the message could be a Java String object ,the Following 
> code DOESN'T work :
>
> String message = "I am a message" ;
> ActionMessage message = new ActionMessage(message);

A quick look at the Javadoc shows that the constructor that takes a String 
expects that String to be a key.  Try this one instead:

http://struts.apache.org/api/org/apache/struts/action/ActionMessage.html#ActionMessage(java.lang.String,%20boolean)

[untested]
ActionMessage message = new ActionMessage(message,false);

-- 
Wendy Smoak


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org