wood burning stoves 2.0*
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


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
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
Author

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) {
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


Adios
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
<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.............
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Behaviour on failure of validate in form bean