- New style dialogs can now be nested

- Added reassign action to manage task dialog as per wireframes
- Workflow package list now gets refreshed properly after executing actions i.e. checkin

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@3648 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Gavin Cornwell
2006-08-31 21:24:17 +00:00
parent 6b4d78a321
commit d9f733483d
11 changed files with 451 additions and 119 deletions

View File

@@ -93,7 +93,8 @@
<dialog name="manageTask" page="/jsp/workflow/manage-task-dialog.jsp" <dialog name="manageTask" page="/jsp/workflow/manage-task-dialog.jsp"
managed-bean="ManageTaskDialog" icon="/images/icons/manage_workflow_task_large.gif" managed-bean="ManageTaskDialog" icon="/images/icons/manage_workflow_task_large.gif"
title-id="manage_task_title" description-id="manage_task_desc" /> title-id="manage_task_title" description-id="manage_task_desc"
actions-config-id="manage_task_actions" />
<dialog name="viewCompletedTask" page="/jsp/workflow/view-completed-task-dialog.jsp" <dialog name="viewCompletedTask" page="/jsp/workflow/view-completed-task-dialog.jsp"
managed-bean="ViewCompletedTaskDialog" icon="/images/icons/completed_workflow_task_large.gif" managed-bean="ViewCompletedTaskDialog" icon="/images/icons/completed_workflow_task_large.gif"

View File

@@ -76,6 +76,10 @@
<action idref="start_workflow" /> <action idref="start_workflow" />
</action-group> </action-group>
<action-group id="manage_task_actions">
<action idref="reassign_task" />
</action-group>
<action-group id="dashlet_todo_actions"> <action-group id="dashlet_todo_actions">
<action idref="reassign_task" /> <action idref="reassign_task" />
</action-group> </action-group>

View File

@@ -29,8 +29,10 @@ import org.alfresco.config.ConfigService;
import org.alfresco.web.app.servlet.ExternalAccessServlet; import org.alfresco.web.app.servlet.ExternalAccessServlet;
import org.alfresco.web.bean.NavigationBean; import org.alfresco.web.bean.NavigationBean;
import org.alfresco.web.bean.dialog.DialogManager; import org.alfresco.web.bean.dialog.DialogManager;
import org.alfresco.web.bean.dialog.DialogState;
import org.alfresco.web.bean.repository.Node; import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.wizard.WizardManager; import org.alfresco.web.bean.wizard.WizardManager;
import org.alfresco.web.bean.wizard.WizardState;
import org.alfresco.web.config.DialogsConfigElement; import org.alfresco.web.config.DialogsConfigElement;
import org.alfresco.web.config.NavigationConfigElement; import org.alfresco.web.config.NavigationConfigElement;
import org.alfresco.web.config.NavigationElementReader; import org.alfresco.web.config.NavigationElementReader;
@@ -589,16 +591,51 @@ public class AlfrescoNavigationHandler extends NavigationHandler
// or any overridden outcome that may be present // or any overridden outcome that may be present
if (getViewStack(context).empty() == false) if (getViewStack(context).empty() == false)
{ {
String newViewId = (String)getViewStack(context).pop();
// is there an overidden outcome? // is there an overidden outcome?
String overriddenOutcome = getOutcomeOverride(outcome); String overriddenOutcome = getOutcomeOverride(outcome);
if (overriddenOutcome == null) if (overriddenOutcome == null)
{ {
// there isn't an overidden outcome so go back to the previous view // there isn't an overidden outcome so go back to the previous view
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("Closing " + closingItem + ", going back to view id: " + newViewId); logger.debug("Closing " + closingItem + ", going back to previous page");
// if the top of the stack is not a dialog or wizard just get the
// view id and navigate back to it.
// if the top of the stack is a dialog or wizard retrieve the state
// and setup the appropriate manager with that state, then get the
// appropriate container page and navigate to it.
Object topOfStack = getViewStack(context).pop();
if (logger.isDebugEnabled())
logger.debug("Popped item from the top of the view stack: " + topOfStack);
String newViewId = null;
if (topOfStack instanceof String)
{
newViewId = (String)topOfStack;
}
else if (topOfStack instanceof DialogState)
{
// restore the dialog state and get the dialog container viewId
Application.getDialogManager().restoreState((DialogState)topOfStack);
newViewId = getDialogContainer(context);
}
else if (topOfStack instanceof WizardState)
{
// restore the wizard state and get the wizard container viewId
Application.getWizardManager().restoreState((WizardState)topOfStack);
newViewId = getWizardContainer(context);
}
else
{
if (logger.isWarnEnabled())
logger.warn("Invalid object found on view stack: " + topOfStack);
}
// go to the appropraite page
goToView(context, newViewId); goToView(context, newViewId);
} }
else else
@@ -656,33 +693,66 @@ public class AlfrescoNavigationHandler extends NavigationHandler
* *
* @param context FacesContext * @param context FacesContext
*/ */
@SuppressWarnings("unchecked")
protected void addCurrentViewToStack(FacesContext context) protected void addCurrentViewToStack(FacesContext context)
{ {
// if we are opening a wizard or dialog push the current view // if the current viewId is either the dialog or wizard container page
// id on to the stack, but only if it is different than the // we need to save the state of the current dialog or wizard to the stack
// current view at the top (you can't launch a dialog from
// the same page 2 times in a row!)
// TODO: This wouldn't happen if we could be sure a dialog is // If the current view is a normal page and it is not the same as the
// ALWAYS exited properly, look into a way of ensuring // view currently at the top of the stack (you can't launch a dialog from
// dialogs get closed if a user navigates away from the page, // the same page 2 times in a row so it must mean the user navigated away
// would a PhaseListener help in any way?? // from the first dialog) just add the viewId to the stack
// work out what to add to the stack
String viewId = context.getViewRoot().getViewId(); String viewId = context.getViewRoot().getViewId();
String dialogContainer = getDialogContainer(context);
if (getViewStack(context).empty() || String wizardContainer = getWizardContainer(context);
viewId.equals(getViewStack(context).peek()) == false) Object objectForStack = null;
if (viewId.equals(dialogContainer))
{ {
getViewStack(context).push(viewId); DialogManager dlgMgr = Application.getDialogManager();
objectForStack = dlgMgr.getState();
if (logger.isDebugEnabled()) }
logger.debug("Pushed current view to stack: " + viewId); else if (viewId.equals(wizardContainer))
{
WizardManager wizMgr = Application.getWizardManager();
objectForStack = wizMgr.getState();
} }
else else
{ {
if (getViewStack(context).empty() == false && logger.isDebugEnabled()) objectForStack = viewId;
}
// if the stack is currently empty add the item
Stack stack = getViewStack(context);
if (stack.empty())
{ {
logger.debug("current view is already top the view stack!"); stack.push(objectForStack);
if (logger.isDebugEnabled())
logger.debug("Pushed item to view stack: " + objectForStack);
}
else
{
// if the item to go on to the stack and the top of
// stack are both Strings and equals to each other
// don't add anything to the stack to stop it
// growing unecessarily
Object topOfStack = stack.peek();
if (objectForStack instanceof String &&
topOfStack instanceof String &&
topOfStack.equals(objectForStack))
{
if (logger.isDebugEnabled())
logger.debug("current view is already top of the view stack!");
}
else
{
stack.push(objectForStack);
if (logger.isDebugEnabled())
logger.debug("Pushed item to view stack: " + objectForStack);
} }
} }
} }
@@ -725,13 +795,13 @@ public class AlfrescoNavigationHandler extends NavigationHandler
* the users session, will never be null * the users session, will never be null
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private Stack<String> getViewStack(FacesContext context) private Stack getViewStack(FacesContext context)
{ {
Stack<String> viewStack = (Stack)context.getExternalContext().getSessionMap().get(VIEW_STACK); Stack viewStack = (Stack)context.getExternalContext().getSessionMap().get(VIEW_STACK);
if (viewStack == null) if (viewStack == null)
{ {
viewStack = new Stack<String>(); viewStack = new Stack();
context.getExternalContext().getSessionMap().put(VIEW_STACK, viewStack); context.getExternalContext().getSessionMap().put(VIEW_STACK, viewStack);
} }

View File

@@ -58,6 +58,11 @@ public abstract class BaseDialogBean implements IDialogBean
this.isFinished = false; this.isFinished = false;
} }
public void restored()
{
// do nothing by default, subclasses can override if necessary
}
public String cancel() public String cancel()
{ {
return getDefaultCancelOutcome(); return getDefaultCancelOutcome();

View File

@@ -20,11 +20,10 @@ import org.alfresco.web.ui.common.component.UIActionLink;
* *
* @author gavinc * @author gavinc
*/ */
public class DialogManager public final class DialogManager
{ {
protected IDialogBean currentDialog; private DialogState currentDialogState;
protected DialogConfig currentDialogConfig; private Map<String, String> paramsToApply;
protected Map<String, String> currentDialogParams;
/** /**
* Action handler used to setup parameters for the dialog being launched * Action handler used to setup parameters for the dialog being launched
@@ -38,7 +37,7 @@ public class DialogManager
if (component instanceof UIActionLink) if (component instanceof UIActionLink)
{ {
// store the parameters // store the parameters
this.currentDialogParams = ((UIActionLink)component).getParameterMap(); this.paramsToApply = ((UIActionLink)component).getParameterMap();
} }
} }
@@ -49,22 +48,48 @@ public class DialogManager
*/ */
public void setCurrentDialog(DialogConfig config) public void setCurrentDialog(DialogConfig config)
{ {
this.currentDialogConfig = config; String beanName = config.getManagedBean();
IDialogBean dialog = (IDialogBean)FacesHelper.getManagedBean(
String beanName = this.currentDialogConfig.getManagedBean();
this.currentDialog = (IDialogBean)FacesHelper.getManagedBean(
FacesContext.getCurrentInstance(), beanName); FacesContext.getCurrentInstance(), beanName);
if (this.currentDialog == null) if (dialog == null)
{ {
throw new AlfrescoRuntimeException("Failed to find managed bean '" + beanName + "'"); throw new AlfrescoRuntimeException("Failed to find managed bean '" + beanName + "'");
} }
// initialise the managed bean // initialise the managed bean
this.currentDialog.init(this.currentDialogParams); dialog.init(this.paramsToApply);
// reset the current parameters so subsequent dialogs don't get them // reset the current parameters so subsequent dialogs don't get them
this.currentDialogParams = null; this.paramsToApply = null;
// create the DialogState object
this.currentDialogState = new DialogState(config, dialog);
}
/**
* Returns the state of the currently active dialog
*
* @return Current dialog's state
*/
public DialogState getState()
{
return this.currentDialogState;
}
/**
* Restores the dialog represented by the given DialogState object.
* NOTE: The dialog's restored() method is also called during this
* method.
*
* @param state The DialogState for the dialog to restore
*/
public void restoreState(DialogState state)
{
this.currentDialogState = state;
// retrieve the dialog and call it's restored() method
this.currentDialogState.getDialog().restored();
} }
/** /**
@@ -74,7 +99,7 @@ public class DialogManager
*/ */
public DialogConfig getCurrentDialog() public DialogConfig getCurrentDialog()
{ {
return this.currentDialogConfig; return this.currentDialogState.getConfig();
} }
/** /**
@@ -84,7 +109,7 @@ public class DialogManager
*/ */
public IDialogBean getBean() public IDialogBean getBean()
{ {
return this.currentDialog; return this.currentDialogState.getDialog();
} }
/** /**
@@ -94,7 +119,7 @@ public class DialogManager
*/ */
public String getIcon() public String getIcon()
{ {
return this.currentDialogConfig.getIcon(); return this.currentDialogState.getConfig().getIcon();
} }
/** /**
@@ -105,7 +130,7 @@ public class DialogManager
public String getErrorMessage() public String getErrorMessage()
{ {
return Application.getMessage(FacesContext.getCurrentInstance(), return Application.getMessage(FacesContext.getCurrentInstance(),
this.currentDialogConfig.getErrorMessageId()); this.currentDialogState.getConfig().getErrorMessageId());
} }
/** /**
@@ -115,7 +140,7 @@ public class DialogManager
*/ */
public String getTitle() public String getTitle()
{ {
String title = this.currentDialogConfig.getTitleId(); String title = this.currentDialogState.getConfig().getTitleId();
if (title != null) if (title != null)
{ {
@@ -123,7 +148,7 @@ public class DialogManager
} }
else else
{ {
title = this.currentDialogConfig.getTitle(); title = this.currentDialogState.getConfig().getTitle();
} }
return title; return title;
@@ -136,7 +161,7 @@ public class DialogManager
*/ */
public String getDescription() public String getDescription()
{ {
String desc = this.currentDialogConfig.getDescriptionId(); String desc = this.currentDialogState.getConfig().getDescriptionId();
if (desc != null) if (desc != null)
{ {
@@ -144,7 +169,7 @@ public class DialogManager
} }
else else
{ {
desc = this.currentDialogConfig.getDescription(); desc = this.currentDialogState.getConfig().getDescription();
} }
return desc; return desc;
@@ -158,7 +183,7 @@ public class DialogManager
*/ */
public String getActions() public String getActions()
{ {
return this.currentDialogConfig.getActionsConfigId(); return this.currentDialogState.getConfig().getActionsConfigId();
} }
/** /**
@@ -168,7 +193,7 @@ public class DialogManager
*/ */
public String getPage() public String getPage()
{ {
return this.currentDialogConfig.getPage(); return this.currentDialogState.getConfig().getPage();
} }
/** /**
@@ -178,7 +203,7 @@ public class DialogManager
*/ */
public boolean isOKButtonVisible() public boolean isOKButtonVisible()
{ {
return this.currentDialogConfig.isOKButtonVisible(); return this.currentDialogState.getConfig().isOKButtonVisible();
} }
/** /**
@@ -191,10 +216,10 @@ public class DialogManager
List<DialogButtonConfig> buttons = null; List<DialogButtonConfig> buttons = null;
// get a list of buttons to display from the configuration // get a list of buttons to display from the configuration
List<DialogButtonConfig> cfgButtons = this.currentDialogConfig.getButtons(); List<DialogButtonConfig> cfgButtons = this.currentDialogState.getConfig().getButtons();
// get a list of buttons added dynamically by the dialog // get a list of buttons added dynamically by the dialog
List<DialogButtonConfig> dynButtons = this.currentDialog.getAdditionalButtons(); List<DialogButtonConfig> dynButtons = this.currentDialogState.getDialog().getAdditionalButtons();
if (cfgButtons != null && dynButtons != null) if (cfgButtons != null && dynButtons != null)
{ {
@@ -223,7 +248,7 @@ public class DialogManager
*/ */
public String getCancelButtonLabel() public String getCancelButtonLabel()
{ {
return this.currentDialog.getCancelButtonLabel(); return this.currentDialogState.getDialog().getCancelButtonLabel();
} }
/** /**
@@ -233,7 +258,7 @@ public class DialogManager
*/ */
public String getFinishButtonLabel() public String getFinishButtonLabel()
{ {
return this.currentDialog.getFinishButtonLabel(); return this.currentDialogState.getDialog().getFinishButtonLabel();
} }
/** /**
@@ -243,7 +268,7 @@ public class DialogManager
*/ */
public boolean getFinishButtonDisabled() public boolean getFinishButtonDisabled()
{ {
return this.currentDialog.getFinishButtonDisabled(); return this.currentDialogState.getDialog().getFinishButtonDisabled();
} }
/** /**
@@ -253,7 +278,7 @@ public class DialogManager
*/ */
public String finish() public String finish()
{ {
return this.currentDialog.finish(); return this.currentDialogState.getDialog().finish();
} }
/** /**
@@ -263,6 +288,6 @@ public class DialogManager
*/ */
public String cancel() public String cancel()
{ {
return this.currentDialog.cancel(); return this.currentDialogState.getDialog().cancel();
} }
} }

View File

@@ -0,0 +1,53 @@
package org.alfresco.web.bean.dialog;
import org.alfresco.web.app.AlfrescoNavigationHandler;
import org.alfresco.web.config.DialogsConfigElement.DialogConfig;
/**
* Object responsible for holding the current state of an active dialog.
*
* @author gavinc
*/
public final class DialogState
{
private DialogConfig config;
private IDialogBean dialog;
/**
* Default constructor
*
* @param config The configuration for the dialog
* @param dialog The dialog bean instance
*/
public DialogState(DialogConfig config, IDialogBean dialog)
{
this.config = config;
this.dialog = dialog;
}
/**
* Returns the configuration for the dialog
*
* @return The dialog configuration
*/
public DialogConfig getConfig()
{
return config;
}
/**
* Returns the bean representing the dialog instance
*
* @return The dialog bean instance
*/
public IDialogBean getDialog()
{
return dialog;
}
@Override
public String toString()
{
return AlfrescoNavigationHandler.DIALOG_PREFIX + this.config.getName();
}
}

View File

@@ -19,6 +19,11 @@ public interface IDialogBean
*/ */
public void init(Map<String, String> parameters); public void init(Map<String, String> parameters);
/**
* Called when the dialog is restored after a nested dialog is closed
*/
public void restored();
/** /**
* Method handler called when the cancel button of the dialog is pressed * Method handler called when the cancel button of the dialog is pressed
* *

View File

@@ -12,6 +12,7 @@ import javax.faces.event.ActionEvent;
import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.web.app.Application; import org.alfresco.web.app.Application;
import org.alfresco.web.app.servlet.FacesHelper; import org.alfresco.web.app.servlet.FacesHelper;
import org.alfresco.web.bean.dialog.DialogState;
import org.alfresco.web.config.WizardsConfigElement.ConditionalPageConfig; import org.alfresco.web.config.WizardsConfigElement.ConditionalPageConfig;
import org.alfresco.web.config.WizardsConfigElement.PageConfig; import org.alfresco.web.config.WizardsConfigElement.PageConfig;
import org.alfresco.web.config.WizardsConfigElement.StepConfig; import org.alfresco.web.config.WizardsConfigElement.StepConfig;
@@ -26,16 +27,12 @@ import org.apache.commons.logging.LogFactory;
* *
* @author gavinc * @author gavinc
*/ */
public class WizardManager public final class WizardManager
{ {
private static Log logger = LogFactory.getLog(WizardManager.class); private static Log logger = LogFactory.getLog(WizardManager.class);
protected int currentStep = 1; private WizardState currentWizardState;
protected PageConfig currentPageCfg; private Map<String, String> paramsToApply;
protected WizardConfig currentWizardConfig;
protected IWizardBean currentWizard;
protected List<StepConfig> steps;
protected Map<String, String> currentWizardParams;
/** /**
* Action handler used to setup parameters for the wizard being launched * Action handler used to setup parameters for the wizard being launched
@@ -49,7 +46,7 @@ public class WizardManager
if (component instanceof UIActionLink) if (component instanceof UIActionLink)
{ {
// store the parameters // store the parameters
this.currentWizardParams = ((UIActionLink)component).getParameterMap(); this.paramsToApply = ((UIActionLink)component).getParameterMap();
} }
} }
@@ -60,31 +57,53 @@ public class WizardManager
*/ */
public void setCurrentWizard(WizardConfig config) public void setCurrentWizard(WizardConfig config)
{ {
this.currentStep = 1; String beanName = config.getManagedBean();
this.currentWizardConfig = config; IWizardBean wizard = (IWizardBean)FacesHelper.getManagedBean(
String beanName = this.currentWizardConfig.getManagedBean();
this.currentWizard = (IWizardBean)FacesHelper.getManagedBean(
FacesContext.getCurrentInstance(), beanName); FacesContext.getCurrentInstance(), beanName);
if (this.currentWizard == null) if (wizard == null)
{ {
throw new AlfrescoRuntimeException("Failed to find managed bean '" + beanName + "'"); throw new AlfrescoRuntimeException("Failed to find managed bean '" + beanName + "'");
} }
// initialise the managed bean // initialise the managed bean
this.currentWizard.init(this.currentWizardParams); wizard.init(this.paramsToApply);
// reset the current parameters so subsequent wizards don't get them // reset the current parameters so subsequent wizards don't get them
this.currentWizardParams = null; this.paramsToApply = null;
// get the steps for the wizard // create the WizardState object
this.steps = this.currentWizardConfig.getStepsAsList(); this.currentWizardState = new WizardState(config, wizard);
// setup the first step // setup the first step
determineCurrentPage(); determineCurrentPage();
} }
/**
* Returns the state of the currently active wizard
*
* @return Current wizard's state
*/
public WizardState getState()
{
return this.currentWizardState;
}
/**
* Restores the wizard represented by the given WizardState object.
* NOTE: The wizard's restored() method is also called during this
* method.
*
* @param state The WizardState for the wizard to restore
*/
public void restoreState(WizardState state)
{
this.currentWizardState = state;
// retrieve the wizard and call it's restored() method
this.currentWizardState.getWizard().restored();
}
/** /**
* Returns the config for the current wizard * Returns the config for the current wizard
* *
@@ -92,7 +111,7 @@ public class WizardManager
*/ */
public WizardConfig getCurrentWizard() public WizardConfig getCurrentWizard()
{ {
return this.currentWizardConfig; return this.currentWizardState.getConfig();
} }
/** /**
@@ -102,7 +121,7 @@ public class WizardManager
*/ */
public IWizardBean getBean() public IWizardBean getBean()
{ {
return this.currentWizard; return this.currentWizardState.getWizard();
} }
/** /**
@@ -112,7 +131,7 @@ public class WizardManager
*/ */
public String getIcon() public String getIcon()
{ {
return this.currentWizardConfig.getIcon(); return this.currentWizardState.getConfig().getIcon();
} }
/** /**
@@ -123,7 +142,7 @@ public class WizardManager
public String getErrorMessage() public String getErrorMessage()
{ {
return Application.getMessage(FacesContext.getCurrentInstance(), return Application.getMessage(FacesContext.getCurrentInstance(),
this.currentWizardConfig.getErrorMessageId()); this.currentWizardState.getConfig().getErrorMessageId());
} }
/** /**
@@ -133,7 +152,7 @@ public class WizardManager
*/ */
public String getTitle() public String getTitle()
{ {
String title = this.currentWizardConfig.getTitleId(); String title = this.currentWizardState.getConfig().getTitleId();
if (title != null) if (title != null)
{ {
@@ -141,7 +160,7 @@ public class WizardManager
} }
else else
{ {
title = this.currentWizardConfig.getTitle(); title = this.currentWizardState.getConfig().getTitle();
} }
return title; return title;
@@ -154,7 +173,7 @@ public class WizardManager
*/ */
public String getDescription() public String getDescription()
{ {
String desc = this.currentWizardConfig.getDescriptionId(); String desc = this.currentWizardState.getConfig().getDescriptionId();
if (desc != null) if (desc != null)
{ {
@@ -162,7 +181,7 @@ public class WizardManager
} }
else else
{ {
desc = this.currentWizardConfig.getDescription(); desc = this.currentWizardState.getConfig().getDescription();
} }
return desc; return desc;
@@ -175,7 +194,7 @@ public class WizardManager
*/ */
public int getCurrentStep() public int getCurrentStep()
{ {
return this.currentStep; return this.currentWizardState.getCurrentStep();
} }
/** /**
@@ -185,7 +204,7 @@ public class WizardManager
*/ */
public String getCurrentStepAsString() public String getCurrentStepAsString()
{ {
return Integer.toString(this.currentStep); return Integer.toString(this.currentWizardState.getCurrentStep());
} }
/** /**
@@ -197,7 +216,8 @@ public class WizardManager
*/ */
public String getCurrentStepName() public String getCurrentStepName()
{ {
return ((StepConfig)this.steps.get(this.currentStep-1)).getName(); return ((StepConfig)this.currentWizardState.getSteps().get(
this.currentWizardState.getCurrentStep()-1)).getName();
} }
/** /**
@@ -207,12 +227,12 @@ public class WizardManager
*/ */
public List<UIListItem> getStepItems() public List<UIListItem> getStepItems()
{ {
List<UIListItem> items = new ArrayList<UIListItem>(this.steps.size()); List<UIListItem> items = new ArrayList<UIListItem>(this.currentWizardState.getSteps().size());
for (int x = 0; x < this.steps.size(); x++) for (int x = 0; x < this.currentWizardState.getSteps().size(); x++)
{ {
String uiStepNumber = Integer.toString(x + 1); String uiStepNumber = Integer.toString(x + 1);
StepConfig stepCfg = this.steps.get(x); StepConfig stepCfg = this.currentWizardState.getSteps().get(x);
UIListItem item = new UIListItem(); UIListItem item = new UIListItem();
item.setValue(uiStepNumber); item.setValue(uiStepNumber);
@@ -255,7 +275,7 @@ public class WizardManager
*/ */
public String getPage() public String getPage()
{ {
return this.currentPageCfg.getPath(); return this.currentWizardState.getCurrentPageCfg().getPath();
} }
/** /**
@@ -265,7 +285,7 @@ public class WizardManager
*/ */
public String getStepTitle() public String getStepTitle()
{ {
String title = this.currentPageCfg.getTitleId(); String title = this.currentWizardState.getCurrentPageCfg().getTitleId();
if (title != null) if (title != null)
{ {
@@ -273,7 +293,7 @@ public class WizardManager
} }
else else
{ {
title = this.currentPageCfg.getTitle(); title = this.currentWizardState.getCurrentPageCfg().getTitle();
} }
return title; return title;
@@ -286,7 +306,7 @@ public class WizardManager
*/ */
public String getStepDescription() public String getStepDescription()
{ {
String desc = this.currentPageCfg.getDescriptionId(); String desc = this.currentWizardState.getCurrentPageCfg().getDescriptionId();
if (desc != null) if (desc != null)
{ {
@@ -294,7 +314,7 @@ public class WizardManager
} }
else else
{ {
desc = this.currentPageCfg.getDescription(); desc = this.currentWizardState.getCurrentPageCfg().getDescription();
} }
return desc; return desc;
@@ -307,7 +327,7 @@ public class WizardManager
*/ */
public String getStepInstructions() public String getStepInstructions()
{ {
String instruction = this.currentPageCfg.getInstructionId(); String instruction = this.currentWizardState.getCurrentPageCfg().getInstructionId();
if (instruction != null) if (instruction != null)
{ {
@@ -315,7 +335,7 @@ public class WizardManager
} }
else else
{ {
instruction = this.currentPageCfg.getInstruction(); instruction = this.currentWizardState.getCurrentPageCfg().getInstruction();
} }
return instruction; return instruction;
@@ -328,7 +348,7 @@ public class WizardManager
*/ */
public String getNextButtonLabel() public String getNextButtonLabel()
{ {
return this.currentWizard.getNextButtonLabel(); return this.currentWizardState.getWizard().getNextButtonLabel();
} }
/** /**
@@ -338,13 +358,13 @@ public class WizardManager
*/ */
public boolean getNextButtonDisabled() public boolean getNextButtonDisabled()
{ {
if (this.currentStep == this.steps.size()) if (this.currentWizardState.getCurrentStep() == this.currentWizardState.getSteps().size())
{ {
return true; return true;
} }
else else
{ {
return this.currentWizard.getNextButtonDisabled(); return this.currentWizardState.getWizard().getNextButtonDisabled();
} }
} }
@@ -355,7 +375,7 @@ public class WizardManager
*/ */
public String getBackButtonLabel() public String getBackButtonLabel()
{ {
return this.currentWizard.getBackButtonLabel(); return this.currentWizardState.getWizard().getBackButtonLabel();
} }
/** /**
@@ -365,7 +385,7 @@ public class WizardManager
*/ */
public boolean getBackButtonDisabled() public boolean getBackButtonDisabled()
{ {
if (this.currentStep == 1) if (this.currentWizardState.getCurrentStep() == 1)
{ {
return true; return true;
} }
@@ -382,7 +402,7 @@ public class WizardManager
*/ */
public String getCancelButtonLabel() public String getCancelButtonLabel()
{ {
return this.currentWizard.getCancelButtonLabel(); return this.currentWizardState.getWizard().getCancelButtonLabel();
} }
/** /**
@@ -392,7 +412,7 @@ public class WizardManager
*/ */
public String getFinishButtonLabel() public String getFinishButtonLabel()
{ {
return this.currentWizard.getFinishButtonLabel(); return this.currentWizardState.getWizard().getFinishButtonLabel();
} }
/** /**
@@ -402,13 +422,13 @@ public class WizardManager
*/ */
public boolean getFinishButtonDisabled() public boolean getFinishButtonDisabled()
{ {
if (this.currentStep == this.steps.size()) if (this.currentWizardState.getCurrentStep() == this.currentWizardState.getSteps().size())
{ {
return false; return false;
} }
else else
{ {
return this.currentWizard.getFinishButtonDisabled(); return this.currentWizardState.getWizard().getFinishButtonDisabled();
} }
} }
@@ -419,13 +439,16 @@ public class WizardManager
*/ */
public void next() public void next()
{ {
this.currentStep++; // calculate next step number and update wizard state
int currentStep = this.currentWizardState.getCurrentStep();
currentStep++;
this.currentWizardState.setCurrentStep(currentStep);
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("next called, current step is now: " + this.currentStep); logger.debug("next called, current step is now: " + this.currentWizardState.getCurrentStep());
// tell the wizard the next button has been pressed // tell the wizard the next button has been pressed
this.currentWizard.next(); this.currentWizardState.getWizard().next();
determineCurrentPage(); determineCurrentPage();
} }
@@ -437,13 +460,16 @@ public class WizardManager
*/ */
public void back() public void back()
{ {
this.currentStep--; // calculate next step number and update wizard state
int currentStep = this.currentWizardState.getCurrentStep();
currentStep--;
this.currentWizardState.setCurrentStep(currentStep);
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("back called, current step is now: " + this.currentStep); logger.debug("back called, current step is now: " + this.currentWizardState.getCurrentStep());
// tell the wizard the back button has been pressed // tell the wizard the back button has been pressed
this.currentWizard.back(); this.currentWizardState.getWizard().back();
determineCurrentPage(); determineCurrentPage();
} }
@@ -455,7 +481,7 @@ public class WizardManager
*/ */
public String finish() public String finish()
{ {
return this.currentWizard.finish(); return this.currentWizardState.getWizard().finish();
} }
/** /**
@@ -465,7 +491,7 @@ public class WizardManager
*/ */
public String cancel() public String cancel()
{ {
return this.currentWizard.cancel(); return this.currentWizardState.getWizard().cancel();
} }
/** /**
@@ -473,10 +499,14 @@ public class WizardManager
*/ */
protected void determineCurrentPage() protected void determineCurrentPage()
{ {
this.currentPageCfg = null; // reset the current page config in the state object
this.currentWizardState.setCurrentPageCfg(null);
PageConfig currentPageCfg = null;
// get the config for the current step position // get the config for the current step position
StepConfig stepCfg = this.steps.get(this.currentStep-1); StepConfig stepCfg = this.currentWizardState.getSteps().get(
this.currentWizardState.getCurrentStep()-1);
// is the step conditional? // is the step conditional?
if (stepCfg.hasConditionalPages()) if (stepCfg.hasConditionalPages())
@@ -497,25 +527,28 @@ public class WizardManager
Object obj = vb.getValue(context); Object obj = vb.getValue(context);
if (obj instanceof Boolean && ((Boolean)obj).booleanValue()) if (obj instanceof Boolean && ((Boolean)obj).booleanValue())
{ {
this.currentPageCfg = pageCfg; currentPageCfg = pageCfg;
break; break;
} }
} }
} }
// if none of the conditions passed use the default page // if none of the conditions passed use the default page
if (this.currentPageCfg == null) if (currentPageCfg == null)
{ {
this.currentPageCfg = stepCfg.getDefaultPage(); currentPageCfg = stepCfg.getDefaultPage();
} }
if (this.currentPageCfg == null) if (currentPageCfg == null)
{ {
throw new AlfrescoRuntimeException("Failed to determine page for step '" + stepCfg.getName() + throw new AlfrescoRuntimeException("Failed to determine page for step '" + stepCfg.getName() +
"'. Make sure a default page is configured."); "'. Make sure a default page is configured.");
} }
// save the current page config in the state object
this.currentWizardState.setCurrentPageCfg(currentPageCfg);
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("Config for current page: " + this.currentPageCfg); logger.debug("Config for current page: " + this.currentWizardState.getCurrentPageCfg());
} }
} }

View File

@@ -0,0 +1,113 @@
package org.alfresco.web.bean.wizard;
import java.util.List;
import org.alfresco.web.app.AlfrescoNavigationHandler;
import org.alfresco.web.config.WizardsConfigElement.PageConfig;
import org.alfresco.web.config.WizardsConfigElement.StepConfig;
import org.alfresco.web.config.WizardsConfigElement.WizardConfig;
/**
* Object responsible for holding the current state of an active wizard.
*
* @author gavinc
*/
public final class WizardState
{
private int currentStep = 1;
private PageConfig currentPageCfg;
private WizardConfig config;
private IWizardBean wizard;
private List<StepConfig> steps;
/**
* Default constructor
*
* @param config The configuration for the wizard
* @param wizard The wizard bean instance
*/
public WizardState(WizardConfig config, IWizardBean wizard)
{
this.config = config;
this.wizard = wizard;
this.steps = this.config.getStepsAsList();
}
/**
* Sets the configuration for the current page of the wizard
*
* @param currentPageCfg The configuration
*/
public void setCurrentPageCfg(PageConfig currentPageCfg)
{
this.currentPageCfg = currentPageCfg;
}
/**
* Sets the current step the wizard is on
*
* @param currentStep The current step number
*/
public void setCurrentStep(int currentStep)
{
this.currentStep = currentStep;
}
/**
* Returns the wizard bean instance
*
* @return The wizard bean instance
*/
public IWizardBean getWizard()
{
return this.wizard;
}
/**
* Returns the configuration for the current wizard
*
* @return The wizard configuration
*/
public WizardConfig getConfig()
{
return this.config;
}
/**
* Returns the configuration for the current page of the wizard
*
* @return The current page configuration
*/
public PageConfig getCurrentPageCfg()
{
return currentPageCfg;
}
/**
* The current step the wizard is on
*
* @return The current wizard step
*/
public int getCurrentStep()
{
return currentStep;
}
/**
* Returns the list of steps the wizard has
*
* @return List of wizard steps
*/
public List<StepConfig> getSteps()
{
return steps;
}
@Override
public String toString()
{
return AlfrescoNavigationHandler.WIZARD_PREFIX + this.config.getName() +
"[" + this.currentStep + "]";
}
}

View File

@@ -122,6 +122,17 @@ public class ManageTaskDialog extends BaseDialogBean
} }
} }
@Override
public void restored()
{
// reset the workflow package rich list so everything gets re-evaluated
if (this.packageItemsRichList != null)
{
this.packageItemsRichList.setValue(null);
this.packageItemsRichList = null;
}
}
@Override @Override
protected String finishImpl(FacesContext context, String outcome) protected String finishImpl(FacesContext context, String outcome)
throws Exception throws Exception

View File

@@ -85,6 +85,7 @@ public class StartWorkflowWizard extends BaseWizardBean
if (this.packageItemsRichList != null) if (this.packageItemsRichList != null)
{ {
this.packageItemsRichList.setValue(null); this.packageItemsRichList.setValue(null);
this.packageItemsRichList = null;
} }
// TODO: Does this need to be in a read-only transaction?? // TODO: Does this need to be in a read-only transaction??
@@ -105,6 +106,17 @@ public class StartWorkflowWizard extends BaseWizardBean
} }
} }
@Override
public void restored()
{
// reset the workflow package rich list so everything gets re-evaluated
if (this.packageItemsRichList != null)
{
this.packageItemsRichList.setValue(null);
this.packageItemsRichList = null;
}
}
@Override @Override
protected String finishImpl(FacesContext context, String outcome) protected String finishImpl(FacesContext context, String outcome)
throws Exception throws Exception