I'm an experienced Java programmer new to Struts. I have to say so far I'm finding it very frustrating.
My problem is that I get a blank page returned from an ActionForm derived class when I click the associated form's submit button, and secondly that no errors are displayed by the <html:errors/> tag. I have hardcoded an error message in validate, but it isn't displayed.
I *know* validate is called because when I click the form's cancel button, Tomcat correctly finds and performs the forward to an error page - this behaviour is just for testing. Ohh and as if that wasn't enough can't seem to get Log4j to log, but that's secondary for now.
I'm sure this is probably just a case of not having read enough documentation...
From struts-config.xml (relevant tags only) :
<!-- Logon form --> <form-bean name="LogonForm" type="template.form.LogonForm"/>
<!-- Process a user logon --> <action path="/SubmitLogonForm" type="template.action.LogonAction" name="LogonForm" scope="request" input="/logon.jsp"> <forward name="failure" path="/error.jsp" /> <forward name="success" path="/welcome.jsp" /> </action>
when you get a blank page, it means the target is not found (Constants.SUCCESS) in the action-mapping forward. double check your Constants.SUCCESS value. do a println.out of the Constants.SUCCESS in your .execute() before return findForward. you need to resolve the target issue first before addressing the errors not being printed out.
you need to add validate="true" to your action mapping. this tells the struts to validate the form. also, if you are adding error messages inside your action, you need to call saveMessages(request,messages); before returning the forward.
also, what version of struts are you using? ActionErrors are deprecated in 1.2.x. you may want to look at the declarative validation (based on XML file) instead of using the old struts 1.0 validate(). also, instead of creating beans, try configure the bean using form-bean definitions. i suggested these because you are just starting out. it's best to stay away from deprecated features and 'way of programming'. [ May 25, 2005: Message edited by: alan do ]
-/a<br />certified slacker...yes, my last name is 'do' - <a href="http://www.luckycouple.com" target="_blank" rel="nofollow">luckycouple.com</a>