File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Behaviour on failure of validate in form bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Behaviour on failure of validate in form bean" Watch "Behaviour on failure of validate in form bean" New topic

Behaviour on failure of validate in form bean

sandy gupta
Ranch Hand

Joined: Jan 30, 2001
Posts: 228
At the risk of sounding stupid when this one is answered, Heres my problem:
i have a jsp regMain.jsp and RegistrationForm which is the formbean for this jsps form has a validate method as shown
* Validate the properties that have been set from this HTTP request,
* and return an <code>ActionErrors</code> object that encapsulates any
* validation errors that have been found. If no errors are found, return
* <code>null</code> or an <code>ActionErrors</code> object with no
* recorded error messages.
* @param mapping The mapping used to select this instance
* @param request The servlet request we are processing
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {"validate called");
// Perform validator framework validations
// ActionErrors errors = super.validate(mapping, request);
ActionErrors errors = new ActionErrors();"after errors");
// Only need crossfield validations here
if ((password != null && confirmPassword != null) && !password.equals(confirmPassword)) {"password mismatch");
new ActionError("error.password.match"));
if ((emailAddress != null && confirmEmailAddress != null) && !emailAddress.equals(confirmEmailAddress)) {"emailAddress mismatch");
new ActionError(""));
}"returning from validate of form bean");
return errors;
The struts config has the following action mapping for this forms action path:
<!-- Process a user registration STEP - 1 -->
<action path="/submitRegistration"
<forward name="failure" path="/regMain.jsp"/>
<forward name="success_usmd" path="/usmd.jsp"/>
<forward name="success_nurse" path="/nurses.jsp"/>
Now when i submit the form with different email or password, the form beans validate fails and it returns ActionErrors object with size > 0. But thats all i see. The Action Servlet which should dispatch my request to the input form does not do that although i have my input set as regMain.jsp
Can any of u point u'r torch here and throw some light on this.

Matthew Phillips
Ranch Hand

Joined: Mar 09, 2001
Posts: 2676
Try setting your input to /regMain.jsp. I believe I had a similar problem once and that may have been how I resolved it.

Matthew Phillips
sandy gupta
Ranch Hand

Joined: Jan 30, 2001
Posts: 228
I tried almost all the possible combinations i could think of. It has to be something more than that.
sandy gupta
Ranch Hand

Joined: Jan 30, 2001
Posts: 228
Ok i figured it out..
there was a
<!-- The "input" parameter on "action" elements is the name of a
local or global "forward" rather than a module-relative path -->
<set-property property="inputForward" value="false"/>

in the struts config for which the inputForward was set to true ............... this is what was causing the problem changing it to false made it work.............
I agree. Here's the link:
subject: Behaviour on failure of validate in form bean
It's not a secret anymore!