You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jerald Powel <ge...@yahoo.co.uk> on 2003/12/22 03:45:13 UTC
error tag
Hello,
I am handling my errors and constructing an errors object thus:
ActionErrors errors = new ActionErrors();
errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("Initialisation error - userID not found"));
saveErrors(request, errors);
return mapping.findForward(FORWARD_error);
how from the JSP do I iterate over the errors object and retrieve the messages please? I have tried <html:errors/> but nothing was rendered to the screen?
thanks
G
---------------------------------
Yahoo! Messenger - Communicate instantly..."Ping" your friends today! Download Messenger Now
RE: [other] error tag
Posted by "Noel E. Lecaros" <no...@lecaros.net>.
Jerald,
The first parameter to ActionMessages.add() is a string interpreted to be
either ActionMessages.GLOBAL_MESSAGE or a name of one of your form fields.
If you had a field on your form that was named (i.e. property=...)
"username", then if you wished to add a message pertaining to this field,
then you would write: messages.add("username", errorMsg). You're not
getting any messages displayed probably because you don't have a form field
with property="init_message."
Cheers,
Noel
-----Original Message-----
From: Jerald Powel [mailto:geraldpowel@yahoo.co.uk]
Sent: Monday, December 22, 2003 12:26 AM
To: Struts Users Mailing List
Subject: RE: [other] error tag
Hi Noel,
Thanks for that. Since that post, I have opted for constructing an
ActionMessages object and populating it with ActionMessage (s). This being
because I hear ActionError/s are deprecated as of Struts 1.2.
I have set up the Application.properties file under
WEB-INF/classes/resources containing:
initialisation.error=Initialisation error - invalid UserID
I catch the exception thus:
ActionMessages messages = new ActionMessages();
ActionMessage errorMsg = new
ActionMessage("initialisation.error");
messages.add("init_message", errorMsg);
saveMessages(request, messages);
and forward off to the error page, but nothing is rendered.
Any idea here? Perhaps something to do with the init_message string I am
passing? What does that represent?
appreciated
G.
Hi Jerald,
The single-string ActionError class constructor that you are invoking
interprets the parameter passed to it as a key of a message string defined
in your Application.properties file (this file is usually placed under the
classes/resources directory).
HTH
Noel
-----Original Message-----
From: Jerald Powel [mailto:geraldpowel@yahoo.co.uk]
Sent: Sunday, December 21, 2003 9:45 PM
To: Struts Users Mailing List
Subject: [other] error tag
Hello,
I am handling my errors and constructing an errors object thus:
ActionErrors errors = new ActionErrors();
errors.add(ActionErrors.GLOBAL_ERROR, new
ActionError("Initialisation error - userID not found"));
saveErrors(request, errors);
return mapping.findForward(FORWARD_error);
how from the JSP do I iterate over the errors object and retrieve the
messages please? I have tried but nothing was rendered to the
screen?
thanks
G
---------------------------------
Yahoo! Messenger - Communicate instantly..."Ping" your friends today!
Download Messenger Now
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
---------------------------------
Yahoo! Messenger - Communicate instantly..."Ping" your friends today!
Download Messenger Now
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
RE: [other] error tag PS
Posted by Peter Sloots <pe...@xs4all.nl>.
Hi
with<bean:message key="card.title"/> you can read messages from your properties file
btw, If I get nothing back in JSP it's because I forget the taglibs...
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
*********** REPLY SEPARATOR ***********
On 22-12-2003 at 5:37 Jerald Powel wrote:
>it just occurrred to me, perhaps it may be due to the JSP:
>
><html:errors />
>
>as ActionMessages are not soley used for error handling? If this is the
>case, what error tag will extract the error labels defined in my
>Application.properties?
>
>thanks again
>
>
>
>G
>
>
>---------------------------------
> Yahoo! Messenger - Communicate instantly..."Ping" your friends today! Download Messenger Now
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
RE: [other] error tag PS
Posted by Jerald Powel <ge...@yahoo.co.uk>.
it just occurrred to me, perhaps it may be due to the JSP:
<html:errors />
as ActionMessages are not soley used for error handling? If this is the case, what error tag will extract the error labels defined in my Application.properties?
thanks again
G
---------------------------------
Yahoo! Messenger - Communicate instantly..."Ping" your friends today! Download Messenger Now
RE: [other] error tag
Posted by Jerald Powel <ge...@yahoo.co.uk>.
Hi Noel,
Thanks for that. Since that post, I have opted for constructing an ActionMessages object and populating it with ActionMessage (s). This being because I hear ActionError/s are deprecated as of Struts 1.2.
I have set up the Application.properties file under WEB-INF/classes/resources containing:
initialisation.error=Initialisation error - invalid UserID
I catch the exception thus:
ActionMessages messages = new ActionMessages();
ActionMessage errorMsg = new ActionMessage("initialisation.error");
messages.add("init_message", errorMsg);
saveMessages(request, messages);
and forward off to the error page, but nothing is rendered.
Any idea here? Perhaps something to do with the init_message string I am passing? What does that represent?
appreciated
G.
Hi Jerald,
The single-string ActionError class constructor that you are invoking
interprets the parameter passed to it as a key of a message string defined
in your Application.properties file (this file is usually placed under the
classes/resources directory).
HTH
Noel
-----Original Message-----
From: Jerald Powel [mailto:geraldpowel@yahoo.co.uk]
Sent: Sunday, December 21, 2003 9:45 PM
To: Struts Users Mailing List
Subject: [other] error tag
Hello,
I am handling my errors and constructing an errors object thus:
ActionErrors errors = new ActionErrors();
errors.add(ActionErrors.GLOBAL_ERROR, new
ActionError("Initialisation error - userID not found"));
saveErrors(request, errors);
return mapping.findForward(FORWARD_error);
how from the JSP do I iterate over the errors object and retrieve the
messages please? I have tried but nothing was rendered to the
screen?
thanks
G
---------------------------------
Yahoo! Messenger - Communicate instantly..."Ping" your friends today!
Download Messenger Now
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
---------------------------------
Yahoo! Messenger - Communicate instantly..."Ping" your friends today! Download Messenger Now
RE: [other] error tag
Posted by "Noel E. Lecaros" <no...@lecaros.net>.
Hi Jerald,
The single-string ActionError class constructor that you are invoking
interprets the parameter passed to it as a key of a message string defined
in your Application.properties file (this file is usually placed under the
classes/resources directory).
HTH
Noel
-----Original Message-----
From: Jerald Powel [mailto:geraldpowel@yahoo.co.uk]
Sent: Sunday, December 21, 2003 9:45 PM
To: Struts Users Mailing List
Subject: [other] error tag
Hello,
I am handling my errors and constructing an errors object thus:
ActionErrors errors = new ActionErrors();
errors.add(ActionErrors.GLOBAL_ERROR, new
ActionError("Initialisation error - userID not found"));
saveErrors(request, errors);
return mapping.findForward(FORWARD_error);
how from the JSP do I iterate over the errors object and retrieve the
messages please? I have tried <html:errors/> but nothing was rendered to the
screen?
thanks
G
---------------------------------
Yahoo! Messenger - Communicate instantly..."Ping" your friends today!
Download Messenger Now
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org