You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by bort <sp...@rogers.com> on 2004/01/06 19:48:19 UTC
Displaying messages as a result of failure
Hi all
How do I present, to the user, customized messages in the case of an Action
failure? For example, say a user fills and submits a form. The form gets
validated, and control is passed onto the Action. From within the action,
we have a "success" and "failure" forward. In the case of a "failure", I
forward the user back to the same page. What I'd like to do now, however,
is to print out a customized message on this page, explaining what the
problem was.
I realize that this is a rather simple question... so please go easy on me!
TIA
bort
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: Displaying messages as a result of failure
Posted by Tin Pham <tt...@learn.senecac.on.ca>.
Hi,
Here is an article from IBM which takes you step by step through some of the
basic struts. I admit not the best article I have read, but step 6 has the
basics of what you are looking for.
http://www-106.ibm.com/developerworks/websphere/techjournal/0302_fung/fung.html
I recommend picking up any of the excellent Struts books out there from
O'Reilly or Manning.
Tin
"bort" <sp...@rogers.com> wrote in message
news:btevsa$5vv$1@localhost.localdomain...
> Hi all
>
> How do I present, to the user, customized messages in the case of an
Action
> failure? For example, say a user fills and submits a form. The form gets
> validated, and control is passed onto the Action. From within the action,
> we have a "success" and "failure" forward. In the case of a "failure", I
> forward the user back to the same page. What I'd like to do now, however,
> is to print out a customized message on this page, explaining what the
> problem was.
>
> I realize that this is a rather simple question... so please go easy on
me!
>
> TIA
> bort
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: Displaying messages as a result of failure
Posted by bort <sp...@rogers.com>.
Thanks Richard!
"Richard Hightower" <rh...@arc-mind.com> wrote in message
news:CGECIBMAADIPANFCDPPMAECACAAA.rhightower@arc-mind.com...
> step 1) in your action's execute method....
>
> ActionErrors errors = new ActionErrors();
>
> errors.add("userHasFooProblem",new ActionError("message.key"));
> //message.key must be in resource bundle, e.g., application.properties
>
> this.saveErrors(errors);
>
> return mapping.findForward("failure");
>
>
>
> step 2) then in your jsp......
>
>
> <html:messages property="userHasForProblems" />
>
>
> (I did this off the top of my head so if the syntax is wrong opps... it
> should be close).
>
> Rick Hightower
> Developer
>
> Struts/J2EE training -- http://www.arc-mind.com/strutsCourse.htm
>
> Struts/J2EE consulting --
> http://www.arc-mind.com/consulting.htm#StrutsMentoring
>
>
> -----Original Message-----
> From: bort [mailto:spambort@rogers.com]
> Sent: Tuesday, January 06, 2004 11:48 AM
> To: struts-user@jakarta.apache.org
> Subject: Displaying messages as a result of failure
>
>
> Hi all
>
> How do I present, to the user, customized messages in the case of an
Action
> failure? For example, say a user fills and submits a form. The form gets
> validated, and control is passed onto the Action. From within the action,
> we have a "success" and "failure" forward. In the case of a "failure", I
> forward the user back to the same page. What I'd like to do now, however,
> is to print out a customized message on this page, explaining what the
> problem was.
>
> I realize that this is a rather simple question... so please go easy on
me!
>
> TIA
> bort
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
RE: Displaying messages as a result of failure
Posted by Richard Hightower <rh...@arc-mind.com>.
step 1) in your action's execute method....
ActionErrors errors = new ActionErrors();
errors.add("userHasFooProblem",new ActionError("message.key"));
//message.key must be in resource bundle, e.g., application.properties
this.saveErrors(errors);
return mapping.findForward("failure");
step 2) then in your jsp......
<html:messages property="userHasForProblems" />
(I did this off the top of my head so if the syntax is wrong opps... it
should be close).
Rick Hightower
Developer
Struts/J2EE training -- http://www.arc-mind.com/strutsCourse.htm
Struts/J2EE consulting --
http://www.arc-mind.com/consulting.htm#StrutsMentoring
-----Original Message-----
From: bort [mailto:spambort@rogers.com]
Sent: Tuesday, January 06, 2004 11:48 AM
To: struts-user@jakarta.apache.org
Subject: Displaying messages as a result of failure
Hi all
How do I present, to the user, customized messages in the case of an Action
failure? For example, say a user fills and submits a form. The form gets
validated, and control is passed onto the Action. From within the action,
we have a "success" and "failure" forward. In the case of a "failure", I
forward the user back to the same page. What I'd like to do now, however,
is to print out a customized message on this page, explaining what the
problem was.
I realize that this is a rather simple question... so please go easy on me!
TIA
bort
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org