Hello:

I am trying to get errors generated from an Action to display
on a failure page, but the <html:errors/> tag is not generating
any output.

You can see my app by going to 
http://dev.rentclubs.com/rentclubs/register.do

If you submit the form without putting any input, it reloads
the page and the <html:errors/> tag generates a list of errors.

If you fill in the form with junk values and then submit it,
you will get a failure page but it does not show the error I
am generating.

Here is my action class:

public class RegisterAction extends Action {
  public ActionForward execute(ActionMapping mapping,
  ActionForm form, HttpServletRequest request, HttpServletResponse response)
  throws Exception {
    // Add the member to the database
    RegisterForm registerForm = (RegisterForm)form;
    String firstName = registerForm.getFirstName();
    System.out.println( "Found first name: " +firstName);
     
    ActionMessages errors = getErrors(request);
    errors.add(ActionMessages.GLOBAL_MESSAGE ,new
ActionMessage("errors.detail","That name already exists"));

    if( errors.size() <= 0 )
      return mapping.findForward("success");
    else {
      saveErrors(request,errors);
      return mapping.findForward("failure");
    }
  }
}

Here is the struts-config.xml for the register form:
    <action path="/registerForm" type="register.RegisterAction"
name="registerForm" scope="request" input="register.index" validate="true">
      <forward name="failure" path="/registerFailure.do" redirect="true" /> 
      <forward name="success" path="/registerSuccess.do" redirect="true" /> 
    </action>
    <action path="/registerFailure" forward="register.failure" /> 
    <action path="/registerSuccess" forward="register.success" /> 

Here is the code in the failures.jsp page:
<[EMAIL PROTECTED] language="java" %>
<[EMAIL PROTECTED] file="/imports.jsp" %>
<[EMAIL PROTECTED] uri="http://jakarta.apache.org/struts/tags-bean"; 
prefix="bean" %>
<[EMAIL PROTECTED] uri="http://jakarta.apache.org/struts/tags-html"; 
prefix="html" %>
<[EMAIL PROTECTED] uri="http://jakarta.apache.org/struts/tags-tiles"; 
prefix="tiles"
%>

<h1>Registration failed</h1>

Your registration failed because:
<br>
<html:errors/>

If you feel this is not correct, please <a
href="mailto:[EMAIL PROTECTED]">contact customer service.</a>

Any idea why the errors are not showing up?

Thanks,
        Neil

--
Neil Aggarwal, JAMM Consulting, (214) 986-3533, www.JAMMConsulting.com
FREE! Valuable info on how your business can reduce operating costs by
17% or more in 6 months or less! http://newsletter.JAMMConsulting.com


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

Reply via email to