Chris, This works for me:

<c:set var="GLOBAL_ERROR">
  <%=org.apache.struts.action.ActionErrors.GLOBAL_ERROR %>
</c:set>
<html:messages id="errorMsgs"
          message="true"
         property="${GLOBAL_ERROR}"
           header="errors.header"
           footer="errors.footer">
  <c:out value="${errorMsgs}" default="tag-error"
     escapeXml="false"/>
</html:messages>

I think by default your messages tag is not showing errors. That's what the 'property' attribute is for.

Also, although I've forgotten the details - I think that message="true" means that it will pick up the ActionMessages object from the request using a particular key, but you may have to set it to false or use another attribute - because you save your object back to the request differently from me. This is what I do in my action:

// Save messages back to request & session (in case of redirects)
request.setAttribute(Globals.MESSAGE_KEY, messages);

Check out the taglib API.

Adam

On 10/17/2003 09:17 AM Chris Searle wrote:
OK,

Had the problem with using the html:messages with struts-el from the
1.1RC1 build (NullPointerException) - so I've just upgraded to 1.1
(thought I'd already done so).

Now - I get no exception - but I get no message either.

The servlet code:


ActionErrors errors = new ActionErrors();


            errors.add(ActionErrors.GLOBAL_ERROR,
                       new ActionError("message.login.failed"));

saveErrors(request, errors);

forward=mapping.findForward("loginfailed");

And in the jsp (note - this is using tiles - so the rest of the
tags (<html> etc) are not in this file:

<%@ taglib uri="/struts-html-el.tld" prefix="html"%>
<%@ taglib uri="/struts-logic-el.tld" prefix="logic"%>
<%@ taglib uri="/c.tld" prefix="c"%>

<logic:messagesPresent>
  <html:messages id="error">
    <p class="error"><c:out value="${error}"/></p>
  </html:messages>
</logic:messagesPresent>


I am getting sent to the loginfailed mapping - but the message is not displayed - no <p class="error"> tags in the HTML at all.

It must be something stupid on my part - this looks to me to be the
same as examples out on the net and in the docs.

Any hints welcome :-)


-- struts 1.1 + tomcat 5.0.12 + java 1.4.2 Linux 2.4.20 RH9


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



Reply via email to