This should have a simple solution but I am just too thick.
I have got an AbstractWizardFormController working fine after following the jpetstore OrderFormController.java example.
I want to have a back (previous page) button on my pages. Therefore I add something similar to the following in the jsp:
<a class="buttonLink" href="<c:url value="/addjob.htm?_target=0"/>"><input type="button" alignment="center" value="back" /></a>
where: /addjob.htm refers to the controller.
In the controller I add: request.getParameter(PARAM_TARGET) != null to the isFormSubmission method, as follows:
protected boolean isFormSubmission(HttpServletRequest request) {
return super.isFormSubmission(request)
|| request.getParameter(PARAM_FINISH) != null
|| request.getParameter(PARAM_CANCEL) != null
|| request.getParameter(PARAM_TARGET) != null;
}
In the getTargetPage I add:
protected int getTargetPage(HttpServletRequest request, Object command, Errors errors, int currentPage) {
if (request.getParameter(PARAM_TARGET) != null) {
return Integer(request.getParameter(PARAM_TARGET)).intVal ue();
}
if (currentPage == 0) {
return 1;
}
else {
return 2;
}
}
This works fine for the first time a back button is pressed. After this the ?_target=0 remains in the request and it is not possible to move to another page other than the one specified in the _target.
Shouldn't the request clear automatically?


Reply With Quote