mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
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:
@@ -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;
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user