Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Behaviour on failure of validate in form bean

 
sandy gupta
Ranch Hand
Posts: 228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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) {
log.info("validate called");
// Perform validator framework validations
// ActionErrors errors = super.validate(mapping, request);
ActionErrors errors = new ActionErrors();
log.info("after errors");
// Only need crossfield validations here
if ((password != null && confirmPassword != null) && !password.equals(confirmPassword)) {
log.info("password mismatch");
errors.add("password",
new ActionError("error.password.match"));
}
if ((emailAddress != null && confirmEmailAddress != null) && !emailAddress.equals(confirmEmailAddress)) {
log.info("emailAddress mismatch");
errors.add("email",
new ActionError("error.email.match"));
}
log.info("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"
type="com.webmd.registration.action.RegistrationAction"
parameter="method"
name="RegisterForm"
scope="request"
input="regMain.jsp"
validate="true">
<forward name="failure" path="/regMain.jsp"/>
<forward name="success_usmd" path="/usmd.jsp"/>
<forward name="success_nurse" path="/nurses.jsp"/>
</action>
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.
TIA
Sahil
 
Matthew Phillips
Ranch Hand
Posts: 2676
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try setting your input to /regMain.jsp. I believe I had a similar problem once and that may have been how I resolved it.
 
sandy gupta
Ranch Hand
Posts: 228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried almost all the possible combinations i could think of. It has to be something more than that.
 
sandy gupta
Ranch Hand
Posts: 228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok i figured it out..
there was a
<controller>
<!-- 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"/>
</controller>

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.............
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic