You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Michael Mok <mi...@consultech.net.au> on 2001/09/27 11:11:59 UTC

How-To :

Hi All

Thought I would like to share the following example code that demonstrate
how to use the <html:messages> tag.

Following from the email Dirk wrote.

In your action class you will have...

ActionMessages messages=new ActionMessages();
 messages.add(ActionMessages.GLOBAL_MESSAGE,new
ActionMessage("login.succesful.key"));
 saveMessages(request,messages);

In your JSP

<html:messages id="messageid" header="login.successful.header"
footer="login.successful.footer" message="true">
    <bean:write name="messageid"/>
</html:messages>

Regards

Michael Mok


-----Message d'origine-----
De: storck [mailto:dirk.storck@cms.tecmath.de]
Date: lundi 24 septembre 2001 10:07
À: User Struts (E-Mail)
Objet: User-messages from Action-Class to JSP


Hi,

maybe I asked something realy stupid, but how I display user-messages like
"login successfull" on my JSP-Page wich comes from my Action-Class. I know
that I have to use something like that:
ActionMessages messages=new ActionMessages();
 messages.add(ActionMessages.GLOBAL_MESSAGE,new
ActionMessage("login.succesful.key"));
 saveMessages(request,messages);

But how do I display that message now on my JSP-Page.

ANOTHER question: With <html:errors/> I write out all errors at that page
but how can I write a special error at a special place on a JSP-Page. I have
something in mind like a formular with different input-fields and if the
user submits that formular with a wrong or with more wrong fields a
error-message should apear under that wrong field!

Thanks !!!!



+----------------------------------------------------------------+
| Ce courrier ainsi que les fichiers joints sont confidentiels.  |
| Si vous avez recu ce courrier par erreur, veuillez en informer |
| l'administrateur du système : exp-iris@unedic.fr               |
|                          ---------                             |
| Ce message confirme que le courrier a passé le contrôle        |
| antivirus du relais de messagerie Internet avec succés.        |
+----------------------------------------------------------------+