You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Burns, Scott " <Sc...@ps.net> on 2005/02/16 14:18:40 UTC

Problem using saveMessages method

I am not seeing errors in my jsp when using the following code.  When I
use the deprecated method saveErrors the error messages are displayed.
What am I doing wrong?  thanks in advance.

Scott

 

In my Action class I have the following code

if(!handler.registerProduct(key)){
     // key not found 
     errors.add(ActionErrors.GLOBAL_MESSAGE, new
ActionMessage(PRODUCT_KEY_INVALID,REGISTRANT));
     saveMessages(request, errors);

forward = mapping.findForward(BACK); 

}

in my jsp I have 

<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>

<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>

<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>

<html:form action="register">

<logic:messagesPresent>

<font color="#BF0000">

<h2>Please correct the following errors before proceeding:</h2>

</font>

<ul>

<html:messages id="error">

<li><bean:write name="error" /></li>

</html:messages>

</ul>

<br><br>

</logic:messagesPresent>


Re: Problem using saveMessages method

Posted by Niall Pemberton <ni...@blueyonder.co.uk>.
BlankYou've switched to the wrong method. saveErrors(HttpServletRequest, ActionErrors) is deprecated in favour of saveErrors(HttpServletRequest, ActionMessages) - NOT saveMessages() - sveMessages stores messages under a different key to errors.

Niall
  ----- Original Message ----- 
  From: Burns, Scott 
  To: user@struts.apache.org 
  Sent: Wednesday, February 16, 2005 1:18 PM
  Subject: Problem using saveMessages method


  I am not seeing errors in my jsp when using the following code.  When I use the deprecated method saveErrors the error messages are displayed.  What am I doing wrong?  thanks in advance.

  Scott



  In my Action class I have the following code

  if(!handler.registerProduct(key)){
       // key not found 
       errors.add(ActionErrors.GLOBAL_MESSAGE, new ActionMessage(PRODUCT_KEY_INVALID,REGISTRANT));
       saveMessages(request, errors);

  forward = mapping.findForward(BACK); 

  }

  in my jsp I have 

  <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>

  <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>

  <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>

  <%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>

  <html:form action="register">

  <logic:messagesPresent>

  <font color="#BF0000">

  <h2>Please correct the following errors before proceeding:</h2>

  </font>

  <ul>

  <html:messages id="error">

  <li><bean:write name="error" /></li>

  </html:messages>


  </ul>

  <br><br>

  </logic:messagesPresent>