StrutsUser, weren't you are part of this earlier Thread?

http://www.mail-archive.com/user%40struts.apache.org/msg15734.html

Maybe that was a different Struts user. Also this might help (Sorry, mail-archive.com doesn't go back this far. It also has a crappy search, but that's another thread).

Hope this helps,

Erik




Robin Mannering wrote:

Thanks for all the help received on this one..


As pointed out by Joe, the <html:messages> tag is conditional, and when supplying the "parameter" atribute I get exactly what I need.



For reference, it looks like this:


<%-- Display error message keyed under 'usernameError' if it exists --%>


              <html:messages id="error" property="usernameError">

                  <tr>

                    <td></td>

                    <td>${error}</td>

                  </tr>

              </html:messages>

Thanks again all!




-----Original Message-----

From: Joe Germuska [mailto:[EMAIL PROTECTED]

Sent: 05 October 2004 14:00

To: Struts Users Mailing List

Subject: RE: ActionError and JSP display



At 1:45 PM +0100 10/5/04, Robin Mannering wrote:


Hi,





I was intending to use <html:errors property="username"/>,



specifying the property for display, but it still doesn't allow me



to test for it's existence.





What I'd like to do is test if an error exists, then add a new HTML



table row and cell into the output containing the error message,



otherwise I do not want to create the HTML table row and cell at all.




Is there a way to do this ?




Personally, I think <html:errors> is "the old way", although at least
one committer has expressed a preference for it.  I prefer
<html:messages>  It is essentially a combination conditional block
and iterator.  Here is my "standard" error messages JSP block:


<html:messages id="msg"><div class="error"><c:out value="${msg}" /></div></html:messages>


By default, it looks for an ActionMessages object saved using Struts' "saveErrors" semantics (that is, stored in the request under "org.apache.struts.action.ERROR" You can set the "message" attribute to "true" to get "messages" instead, and you can set the "name" attribute to fetch any arbitrary ActionMessages. Furthermore, you can use the "property" attribute to constrain the condition to only if the ActionMessages contains messages for the given property. If you're not using the JSTL, you can use <bean:write> instead of <c:out> to display the message itself. And, of course, you can use table rows instead of divs to wrap each message provided by the iterator.


http://struts.apache.org/userGuide/struts-html.html#messages


Hope this helps...


Joe


There's also the <logic:messagesPresent/> tag that takes a property attribute: http://struts.apache.org/userGuide/struts-logic.html#messagesPresent



StrutsUser wrote:

Martin,
I need to manually iterate through the messages to find out if the message is empty or not in the JSP.
Thanks,
Leonard
----- Original Message ----- From: "Laconia Data Systems" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Saturday, December 11, 2004 5:37 AM
Subject: Re: html:errors and manual iterate



Leonard-
The Action class getErrors() method returns the contents of ActionErrors or
creates new ActionMessages object
http://struts.apache.org/api/org/apache/struts/action/Action.html
Is this what you're looking for?
Martin-
----- Original Message ----- From: "StrutsUser" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, December 11, 2004 8:19 AM
Subject: html:errors and manual iterate



I have a situation in which I have to add an ActionError without a message
(use it to indicate field in error on the page). If I use the generic
html:errors tag, it displays lineitems without a message. Is there a way to
iterate over html:errors to check that a message should be displayed only if
the message is not empty.
Thanks in advance for any suggestions,
Leonard



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



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



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



Reply via email to