Here's how I do it:

<%
ActionErrors ae = ( ActionErrors) request.getAttribute( Action.ERROR_KEY);
boolean err = false;
if( ae != null) { err = true;   }
%>

You can also test for specific errors or for action messages.  Then,
wherever you want anything to occur on the page:

<% if( err) { %>
  [whatever]
<% } %>

Mark

-----Original Message-----
From: Galbraith, Paul [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, August 20, 2002 8:38 AM

Amol,

I'm very new to Struts myself...just learning my way around, really, so I'd
love to hear someone else's opinion on this.  The way I'd approach this is
to use the <logic:notPresent/> tag in the JSP to show your status message
only if there isn't an error object.  E.g.:

<logic:notPresent name="<%= org.apache.struts.action.Action.ERROR_KEY %>">
User added, any other suckers?
</logic:notPresent>

Paul


-----Original Message-----
From: amolk [mailto:[EMAIL PROTECTED]]
Sent: August 20, 2002 1:58 AM
To: [EMAIL PROTECTED]
Subject: separating status messages and error messages-Getting the
design right.


Hi all,
I have just shifted from servlets to jsp + struts. I am still new to both.
I have to create some jsp pages corresponding to some user actions.
For example, the application administrator can click on add user link ( from
left band menu which is in a separete frame ) and will be presented with a
form which he can fill can click on add to add the user. On submit, the
corresponding action class's perform is invoked and the same page has to be
shown back to the user, this time, with a status message saying "user added
successfully. Add another?" If the operation fails, an appropriate message
is displayed using the <html:errors/>
My problem is the following:
Where do i handle these status messages? Each page is viewed by the user in
two different scenarios. 1. When the user wishes to perform some task. This
time, there is no status, error message to be shown. Just the jsp page,
directly.
2. After the user fill out the form and submits it. The same form reappears
with the appropriate status or error message.
Should i be mixing status and error messages? In that case, how do i handle
different headers and footers for the two?
Or should i be using some custom tags?
Hve been trying out custom tags but since am still new to all this, ( jsp as
well as struts. have been using only servlets till now!!! ) am not able to
take design design decisions based on custom libraries, and stuff.
I would go for a design where maximum html code is present in the jsp file
itself so that my page designers can freely modify/manage it.
Any suggestions? I am not using tiles or anything else. Too many new things
to handle @ a time, specially since i am new to jsp itself!!


thnx in advance,
amol


--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to