Hi:
I'm working with a Struts 1.0 application. I extended Action to create a
base action that handles backwards navigation in a stack fashion.
Each method calls a "saveStep" method to the stack. This step has form,
mapping and dispatch name. Base action has a method called "stepBack"
that can be called from the browser by clicking the "back" button (not
browser back button, but a submit button). This stepBack method executes
the last step in the stack and goes backwards. Another features exists
like checkPoint step, and an undoStep to return from a validation in
Validator Form.
public ActionForward stepBack(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
NavigationStack ns =
this.retrieveNavigationStack(request);
synchronized(ns) {
//if not reloading
StackStep ss = null;
if(this.isTokenValid(request)) {
try {
ns.pop(); //last step, ignore it.
ss = ns.pop();
} catch (Exception e){
return this.handleEmptyStack(mapping, form, request,
response);
}
} else {
ss = ns.getLastPopped();
}
return ss.process(request, response);
}
}
public void saveStep(ActionMapping mapping, ActionForm form,
HttpServletRequest req, String dispatchName, boolean isCheckPoint) {
//si no se indic� invalidar el grabado...
if(this.isStepValid(req)) {
NavigationStack ns =
this.retrieveNavigationStack(req);
synchronized(ns) {
StackStep newStep = new
StackStep(dispatchName, mapping, form, isCheckPoint);
newStep.setServlet(this.getServlet());
//lo apila siempre y cuando sean
distintos (el �ltimo y el nuevo)
if(!newStep.equals(ns.getLast())) {
ns.push(newStep);
}
this.saveNavigationStack(req, ns);
}
}
}
I would like to know what you thing about this kind of navigation
management and know how are you dealing with this problem. With this
solution I can link 2 use case action (I designed one action for each
use case) and click back button to return wherever i was called.
Thanks in advance.
Guillermo Meyer
System Engineer.
EDS Argentina.