struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael McGrady <>
Subject Re: Capturing Previous Action Request
Date Sun, 01 Feb 2004 22:47:47 GMT

At 01:57 PM 2/1/2004, you wrote:
>I am working on a work-flow web app and need to provide the user with the 
>ability to navigate back to their previous page by the use of a "back" 
>button within the web app.... not the browser's back button.
>How can I capture the action mapping that was processed in order to allow 
>the user to navigate back?

You want "back" or "undo"?  The difference is huge.  The mapping is just 
there to capture and to save in a myriad of ways.  You might, for example, 
try something akin to a Do/Undo application even if you want "back", for 
future possibilities.  Some will, I think, recommend the Chain of 
Responsibility Pattern which forwards requests along a chain of 
classes.  That would, in my humble opinion (and the humility is earned), be 
a mistake.  A Command Pattern will give you the ability to change actions 
in the future without affecting the client.

You could do the following, for example:

public interface Command {}
public interface Do extends Command {}
public interface UnDo extends Command {}
public interface ReDo extends Command {}

public class UndoableList {
     private int         maxHistory = 100;
     private LinkedList     history = new LinkedList();
     private LinkedList    redoList = new LinkedList();
     private UndoableListsTemplate() {
         public static UndoableListsTemplate getInstance() {
                 return new UndoableListsTemplate();
     public void invoke(Command command) {
         if (command instanceof Undo) {
         if (command instanceof Redo) {
         if (command instanceof Do) {
         } else {
         if (redoList.size() > 0) {
     private void undo() {
         if (history.size() > 0) {
             Command undoCommand;
             undoCommand = (Command)history.removeFirst();
     private void redo() {
         if (redoList.size() > 0) {
             Command redoCommand;
             redoCommand = (Command)redoList.removeFirst();
     private void addToHistory(Command command) {
         if (history.size() > maxHistory) {


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message