quicklearner
03-01-2007, 11:10 AM
Hello, I am coding a project based on Struts and recently I got a problem caused by validation error. the work flow is that user input data in edit.jsp and then submit to back-side EditAction.java and then should be taken to review.jsp to review their input. Please refer to following information
in struts-config.xml: (baseForm is an ActionForm)
<form-beans>
<form-bean name="baseForm" type="com.TPF.forms.BaseForm" />
</form-beans>
<action-mappings>
<action path="/review" name="baseForm" type="com.TPF.actions.EditAction" input="/pages/edit.jsp" validate="true">
</action-mappings>
in edit.jsp:
<html:form action="/review">
...
</html:form>
The url for edit.jsp is "http://serverName/webroot/edit?param1=p1¶m2=p2". When I submit the form in edit.jsp, URL will become to "http://serverName/webroot/review.do" and being sent to server side. baseForm.validate() will be executed and catch invalid input if any, then return errors to edit.jsp page agaion and show user some error message. the problem is that upon validation failure, control returns to edit.jsp with changed URL, which is "http://serverName/webroot/review.do". Therefore, when I mean to refresh edit.jsp with its original url, it actually submit the form again. Is there any ways I can change the url back when submission is stopped by validation error? Thanks.
in struts-config.xml: (baseForm is an ActionForm)
<form-beans>
<form-bean name="baseForm" type="com.TPF.forms.BaseForm" />
</form-beans>
<action-mappings>
<action path="/review" name="baseForm" type="com.TPF.actions.EditAction" input="/pages/edit.jsp" validate="true">
</action-mappings>
in edit.jsp:
<html:form action="/review">
...
</html:form>
The url for edit.jsp is "http://serverName/webroot/edit?param1=p1¶m2=p2". When I submit the form in edit.jsp, URL will become to "http://serverName/webroot/review.do" and being sent to server side. baseForm.validate() will be executed and catch invalid input if any, then return errors to edit.jsp page agaion and show user some error message. the problem is that upon validation failure, control returns to edit.jsp with changed URL, which is "http://serverName/webroot/review.do". Therefore, when I mean to refresh edit.jsp with its original url, it actually submit the form again. Is there any ways I can change the url back when submission is stopped by validation error? Thanks.