Added ability to pass parameters to wizards and dialogs

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2807 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Gavin Cornwell
2006-05-10 11:33:02 +00:00
parent c953c45c3d
commit 8cd2a68717
13 changed files with 90 additions and 24 deletions

View File

@@ -131,9 +131,9 @@ public abstract class BaseActionWizard extends BaseWizardBean
// Wizard implementation
@Override
public void init()
public void init(Map<String, String> parameters)
{
super.init();
super.init(parameters);
this.action = null;
this.users = null;

View File

@@ -2,6 +2,7 @@ package org.alfresco.web.bean.content;
import java.io.File;
import java.text.MessageFormat;
import java.util.Map;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
@@ -35,9 +36,9 @@ public class AddContentDialog extends BaseContentWizard
}
@Override
public void init()
public void init(Map<String, String> parameters)
{
super.init();
super.init(parameters);
clearUpload();
}
@@ -141,7 +142,7 @@ public class AddContentDialog extends BaseContentWizard
// approach can not be used in the current dialog framework. Until
// we have a pure JSF upload solution we need this initialisation
init();
init(null);
}
/**

View File

@@ -59,9 +59,9 @@ public abstract class BaseContentWizard extends BaseWizardBean
// Wizard implementation
@Override
public void init()
public void init(Map<String, String> parameters)
{
super.init();
super.init(parameters);
this.fileName = null;
this.author = null;

View File

@@ -2,6 +2,7 @@ package org.alfresco.web.bean.content;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.ResourceBundle;
import javax.faces.context.FacesContext;
@@ -47,9 +48,9 @@ public class CreateContentWizard extends BaseContentWizard
}
@Override
public void init()
public void init(Map<String, String> parameters)
{
super.init();
super.init(parameters);
this.content = null;
this.inlineEdit = true;

View File

@@ -38,9 +38,9 @@ public class EditContentPropertiesDialog extends BaseDialogBean
// Dialog implementation
@Override
public void init()
public void init(Map<String, String> parameters)
{
super.init();
super.init(parameters);
// setup the editable node
this.editableNode = new Node(this.browseBean.getDocument().getNodeRef());

View File

@@ -1,6 +1,8 @@
package org.alfresco.web.bean.dialog;
import java.text.MessageFormat;
import java.util.HashMap;
import java.util.Map;
import javax.faces.context.FacesContext;
import javax.transaction.UserTransaction;
@@ -25,6 +27,7 @@ import org.alfresco.web.ui.common.Utils;
*/
public abstract class BaseDialogBean implements IDialogBean
{
protected Map<String, String> parameters;
protected boolean isFinished = false;
// services common to most dialogs
@@ -36,11 +39,19 @@ public abstract class BaseDialogBean implements IDialogBean
protected DictionaryService dictionaryService;
protected NamespaceService namespaceService;
public void init()
public void init(Map<String, String> parameters)
{
// tell any beans to update themselves so the UI gets refreshed
UIContextService.getInstance(FacesContext.getCurrentInstance()).notifyBeans();
// store the parameters, create empty map if necessary
this.parameters = parameters;
if (this.parameters == null)
{
this.parameters = new HashMap<String, String>();
}
// reset the isFinished flag
this.isFinished = false;
}

View File

@@ -1,11 +1,16 @@
package org.alfresco.web.bean.dialog;
import java.util.Map;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.web.app.Application;
import org.alfresco.web.app.servlet.FacesHelper;
import org.alfresco.web.config.DialogsConfigElement.DialogConfig;
import org.alfresco.web.ui.common.component.UIActionLink;
/**
* Bean that manages the dialog framework
@@ -14,8 +19,25 @@ import org.alfresco.web.config.DialogsConfigElement.DialogConfig;
*/
public class DialogManager
{
protected DialogConfig currentDialogConfig;
protected IDialogBean currentDialog;
protected DialogConfig currentDialogConfig;
protected Map<String, String> currentDialogParams;
/**
* Action handler used to setup parameters for the dialog being launched
*
* @param event The event containing the parameters
*/
public void setupParameters(ActionEvent event)
{
// check the component the event come from was an action link
UIComponent component = event.getComponent();
if (component instanceof UIActionLink)
{
// store the parameters
this.currentDialogParams = ((UIActionLink)component).getParameterMap();
}
}
/**
* Sets the current dialog
@@ -36,7 +58,10 @@ public class DialogManager
}
// initialise the managed bean
this.currentDialog.init();
this.currentDialog.init(this.currentDialogParams);
// reset the current parameters so subsequent dialogs don't get them
this.currentDialogParams = null;
}
/**

View File

@@ -1,5 +1,7 @@
package org.alfresco.web.bean.dialog;
import java.util.Map;
/**
* Interface that defines the contract for a dialog backing bean
*
@@ -9,8 +11,10 @@ public interface IDialogBean
{
/**
* Initialises the dialog bean
*
* @param parameters Map of parameters for the dialog
*/
public void init();
public void init(Map<String, String> parameters);
/**
* Method handler called when the cancel button of the dialog is pressed

View File

@@ -81,9 +81,9 @@ public class CreateRuleWizard extends BaseActionWizard
// Wizard implementation
@Override
public void init()
public void init(Map<String, String> parameters)
{
super.init();
super.init(parameters);
this.title = null;
this.description = null;

View File

@@ -50,9 +50,9 @@ public class EditRuleWizard extends CreateRuleWizard
// Wizard implementation
@Override
public void init()
public void init(Map<String, String> parameters)
{
super.init();
super.init(parameters);
// get hold of the current rule details
Rule rule = this.rulesBean.getCurrentRule();

View File

@@ -66,9 +66,9 @@ public class CreateSpaceWizard extends BaseWizardBean
/**
* Initialises the wizard
*/
public void init()
public void init(Map<String, String> parameters)
{
super.init();
super.init(parameters);
// clear the cached query results
if (this.templates != null)

View File

@@ -35,9 +35,9 @@ public class EditSpaceDialog extends BaseDialogBean
protected Node editableNode;
@Override
public void init()
public void init(Map<String, String> parameters)
{
super.init();
super.init(parameters);
// setup the space being edited
this.editableNode = this.browseBean.getActionSpace();

View File

@@ -2,9 +2,12 @@ package org.alfresco.web.bean.wizard;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.el.ValueBinding;
import javax.faces.event.ActionEvent;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.web.app.Application;
@@ -13,6 +16,7 @@ import org.alfresco.web.config.WizardsConfigElement.ConditionalPageConfig;
import org.alfresco.web.config.WizardsConfigElement.PageConfig;
import org.alfresco.web.config.WizardsConfigElement.StepConfig;
import org.alfresco.web.config.WizardsConfigElement.WizardConfig;
import org.alfresco.web.ui.common.component.UIActionLink;
import org.alfresco.web.ui.common.component.UIListItem;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -31,6 +35,23 @@ public class WizardManager
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
*
* @param event The event containing the parameters
*/
public void setupParameters(ActionEvent event)
{
// check the component the event come from was an action link
UIComponent component = event.getComponent();
if (component instanceof UIActionLink)
{
// store the parameters
this.currentWizardParams = ((UIActionLink)component).getParameterMap();
}
}
/**
* Sets the current wizard
@@ -52,7 +73,10 @@ public class WizardManager
}
// initialise the managed bean
this.currentWizard.init();
this.currentWizard.init(this.currentWizardParams);
// reset the current parameters so subsequent wizards don't get them
this.currentWizardParams = null;
// get the steps for the wizard
this.steps = this.currentWizardConfig.getStepsAsList();