mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
- Added error-message-id attribute to dialog and wizard framework
- Added error component to container pages - Removed error component from each dialog/wizard page - Fixed problem where dialog or wizard would not work after an error git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2872 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
<!-- Definition of the create space dialog -->
|
||||
<dialog name="createSpace" page="/jsp/spaces/create-space-dialog.jsp" managed-bean="CreateSpaceDialog"
|
||||
icon="/images/icons/create_space_large.gif" title-id="create_space"
|
||||
description-id="create_space_description" />
|
||||
description-id="create_space_description" error-message-id="error_create_space_dialog" />
|
||||
|
||||
<!-- Definition of the edit space dialog -->
|
||||
<dialog name="editSpace" page="/jsp/spaces/edit-space-dialog.jsp" managed-bean="EditSpaceDialog"
|
||||
|
@@ -90,6 +90,9 @@ public abstract class BaseDialogBean implements IDialogBean
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
// reset the flag so we can re-attempt the operation
|
||||
isFinished = false;
|
||||
|
||||
// rollback the transaction
|
||||
try { if (tx != null) {tx.rollback();} } catch (Exception ex) {}
|
||||
Utils.addErrorMessage(formatErrorMessage(e));
|
||||
|
@@ -94,6 +94,17 @@ public class DialogManager
|
||||
return this.currentDialogConfig.getIcon();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the error message to use in error conditions
|
||||
*
|
||||
* @return The error message
|
||||
*/
|
||||
public String getErrorMessage()
|
||||
{
|
||||
return Application.getMessage(FacesContext.getCurrentInstance(),
|
||||
this.currentDialogConfig.getErrorMessageId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the resolved title to use for the dialog
|
||||
*
|
||||
|
@@ -115,6 +115,17 @@ public class WizardManager
|
||||
return this.currentWizardConfig.getIcon();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the error message to use in error conditions
|
||||
*
|
||||
* @return The error message
|
||||
*/
|
||||
public String getErrorMessage()
|
||||
{
|
||||
return Application.getMessage(FacesContext.getCurrentInstance(),
|
||||
this.currentWizardConfig.getErrorMessageId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the resolved title to use for the wizard
|
||||
*
|
||||
|
@@ -130,11 +130,13 @@ public class DialogsConfigElement extends ConfigElementAdapter
|
||||
protected String titleId;
|
||||
protected String description;
|
||||
protected String descriptionId;
|
||||
protected String errorMsgId = "error_dialog";
|
||||
|
||||
public DialogConfig(String name, String page, String bean,
|
||||
String actionsConfigId, String icon,
|
||||
String title, String titleId,
|
||||
String description, String descriptionId)
|
||||
String description, String descriptionId,
|
||||
String errorMsgId)
|
||||
{
|
||||
// check the mandatory parameters are present
|
||||
ParameterCheck.mandatoryString("name", name);
|
||||
@@ -150,6 +152,11 @@ public class DialogsConfigElement extends ConfigElementAdapter
|
||||
this.titleId = titleId;
|
||||
this.description = description;
|
||||
this.descriptionId = descriptionId;
|
||||
|
||||
if (errorMsgId != null && errorMsgId.length() > 0)
|
||||
{
|
||||
this.errorMsgId = errorMsgId;
|
||||
}
|
||||
}
|
||||
|
||||
public String getDescription()
|
||||
@@ -197,6 +204,11 @@ public class DialogsConfigElement extends ConfigElementAdapter
|
||||
return this.titleId;
|
||||
}
|
||||
|
||||
public String getErrorMessageId()
|
||||
{
|
||||
return this.errorMsgId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@@ -212,7 +224,8 @@ public class DialogsConfigElement extends ConfigElementAdapter
|
||||
buffer.append(" title=").append(this.title);
|
||||
buffer.append(" titleId=").append(this.titleId);
|
||||
buffer.append(" description=").append(this.description);
|
||||
buffer.append(" descriptionId=").append(this.descriptionId).append(")");
|
||||
buffer.append(" descriptionId=").append(this.descriptionId);
|
||||
buffer.append(" errorMsgId=").append(this.errorMsgId).append(")");
|
||||
return buffer.toString();
|
||||
}
|
||||
}
|
||||
|
@@ -41,6 +41,7 @@ public class DialogsElementReader implements ConfigElementReader
|
||||
public static final String ATTR_TITLE_ID = "title-id";
|
||||
public static final String ATTR_DESCRIPTION = "description";
|
||||
public static final String ATTR_DESCRIPTION_ID = "description-id";
|
||||
public static final String ATTR_ERROR_MSG_ID = "error-message-id";
|
||||
|
||||
/**
|
||||
* @see org.alfresco.config.xml.elementreader.ConfigElementReader#parse(org.dom4j.Element)
|
||||
@@ -76,10 +77,11 @@ public class DialogsElementReader implements ConfigElementReader
|
||||
String titleId = item.attributeValue(ATTR_TITLE_ID);
|
||||
String description = item.attributeValue(ATTR_DESCRIPTION);
|
||||
String descriptionId = item.attributeValue(ATTR_DESCRIPTION_ID);
|
||||
String errorMsgId = item.attributeValue(ATTR_ERROR_MSG_ID);
|
||||
|
||||
DialogsConfigElement.DialogConfig cfg = new DialogsConfigElement.DialogConfig(
|
||||
name, page, bean, actions, icon, title, titleId, description,
|
||||
descriptionId);
|
||||
descriptionId, errorMsgId);
|
||||
|
||||
configElement.addDialog(cfg);
|
||||
}
|
||||
|
@@ -656,6 +656,7 @@ public class WebClientConfigTest extends BaseTest
|
||||
assertEquals("icon", "/images/icons/create_space_large.gif", dialog.getIcon());
|
||||
assertEquals("title-id", "create_space_title", dialog.getTitleId());
|
||||
assertEquals("description-id", "create_space_description", dialog.getDescriptionId());
|
||||
assertEquals("error-message-id", "error_create_space_dialog", dialog.getErrorMessageId());
|
||||
assertNull("title should be null", dialog.getTitle());
|
||||
assertNull("description should be null", dialog.getDescription());
|
||||
|
||||
@@ -671,6 +672,7 @@ public class WebClientConfigTest extends BaseTest
|
||||
assertEquals("icon", "/images/icons/create_space_large.gif", dialog.getIcon());
|
||||
assertEquals("title", "Space Details Dialog", dialog.getTitle());
|
||||
assertEquals("description", "Space Details Dialog Decsription", dialog.getDescription());
|
||||
assertEquals("error-message-id", "error_dialog", dialog.getErrorMessageId());
|
||||
assertNull("title-id should be null", dialog.getTitleId());
|
||||
assertNull("description-id should be null", dialog.getDescriptionId());
|
||||
}
|
||||
@@ -741,6 +743,7 @@ public class WebClientConfigTest extends BaseTest
|
||||
assertEquals("icon", "/images/icons/example-logo.gif", wizard.getIcon());
|
||||
assertEquals("title", "Example Wizard Title", wizard.getTitle());
|
||||
assertEquals("description", "Example Wizard Description", wizard.getDescription());
|
||||
assertEquals("error-message-id", "error_wizard", wizard.getErrorMessageId());
|
||||
assertNull("title-id should be null", wizard.getTitleId());
|
||||
assertNull("description-id should be null", wizard.getDescriptionId());
|
||||
|
||||
@@ -760,6 +763,7 @@ public class WebClientConfigTest extends BaseTest
|
||||
assertEquals("icon", "/images/icons/create_space_large.gif", wizard.getIcon());
|
||||
assertEquals("title-id", "advanced_space_details_title", wizard.getTitleId());
|
||||
assertEquals("description-id", "advanced_space_details_description", wizard.getDescriptionId());
|
||||
assertEquals("error-message-id", "error_create_space_wizard", wizard.getErrorMessageId());
|
||||
assertNull("title should be null", wizard.getTitle());
|
||||
assertNull("description should be null", wizard.getDescription());
|
||||
List<StepConfig> steps = wizard.getStepsAsList();
|
||||
|
@@ -160,12 +160,15 @@ public class WizardsConfigElement extends ConfigElementAdapter
|
||||
protected String managedBean;
|
||||
protected String icon;
|
||||
protected String actionsConfigId;
|
||||
protected String errorMsgId = "error_wizard";
|
||||
|
||||
protected Map<String, StepConfig> steps = new LinkedHashMap<String, StepConfig>(4);
|
||||
|
||||
public WizardConfig(String name, String bean,
|
||||
String actionsConfigId, String icon,
|
||||
String title, String titleId,
|
||||
String description, String descriptionId)
|
||||
String description, String descriptionId,
|
||||
String errorMsgId)
|
||||
{
|
||||
super(title, titleId, description, descriptionId);
|
||||
|
||||
@@ -176,6 +179,11 @@ public class WizardsConfigElement extends ConfigElementAdapter
|
||||
this.managedBean = bean;
|
||||
this.icon = icon;
|
||||
this.actionsConfigId = actionsConfigId;
|
||||
|
||||
if (errorMsgId != null && errorMsgId.length() > 0)
|
||||
{
|
||||
this.errorMsgId = errorMsgId;
|
||||
}
|
||||
}
|
||||
|
||||
public String getName()
|
||||
@@ -198,6 +206,11 @@ public class WizardsConfigElement extends ConfigElementAdapter
|
||||
return this.actionsConfigId;
|
||||
}
|
||||
|
||||
public String getErrorMessageId()
|
||||
{
|
||||
return this.errorMsgId;
|
||||
}
|
||||
|
||||
public int getNumberSteps()
|
||||
{
|
||||
return this.steps.size();
|
||||
@@ -244,7 +257,8 @@ public class WizardsConfigElement extends ConfigElementAdapter
|
||||
buffer.append(" title=").append(this.title);
|
||||
buffer.append(" titleId=").append(this.titleId);
|
||||
buffer.append(" description=").append(this.description);
|
||||
buffer.append(" descriptionId=").append(this.descriptionId).append(")");
|
||||
buffer.append(" descriptionId=").append(this.descriptionId);
|
||||
buffer.append(" errorMsgId=").append(this.errorMsgId).append(")");
|
||||
return buffer.toString();
|
||||
}
|
||||
}
|
||||
|
@@ -49,6 +49,7 @@ public class WizardsElementReader implements ConfigElementReader
|
||||
public static final String ATTR_DESCRIPTION_ID = "description-id";
|
||||
public static final String ATTR_INSTRUCTION = "instruction";
|
||||
public static final String ATTR_INSTRUCTION_ID = "instruction-id";
|
||||
public static final String ATTR_ERROR_MSG_ID = "error-message-id";
|
||||
public static final String ATTR_IF = "if";
|
||||
public static final String ATTR_PATH = "path";
|
||||
|
||||
@@ -85,10 +86,11 @@ public class WizardsElementReader implements ConfigElementReader
|
||||
String titleId = wizard.attributeValue(ATTR_TITLE_ID);
|
||||
String description = wizard.attributeValue(ATTR_DESCRIPTION);
|
||||
String descriptionId = wizard.attributeValue(ATTR_DESCRIPTION_ID);
|
||||
String errorMsgId = wizard.attributeValue(ATTR_ERROR_MSG_ID);
|
||||
|
||||
// create the wizard config object
|
||||
WizardsConfigElement.WizardConfig wizardCfg = new WizardsConfigElement.WizardConfig(
|
||||
name, bean, actions, icon, title, titleId, description, descriptionId);
|
||||
name, bean, actions, icon, title, titleId, description, descriptionId, errorMsgId);
|
||||
|
||||
Iterator<Element> steps = wizard.elementIterator(ELEMENT_STEP);
|
||||
while (steps.hasNext())
|
||||
|
@@ -13,7 +13,8 @@
|
||||
<dialogs>
|
||||
<dialog name="createSpace" page="/jsp/dialog/create-space.jsp" managed-bean="NewSpaceDialog"
|
||||
actions-config-id="space-actions" icon="/images/icons/create_space_large.gif"
|
||||
title-id="create_space_title" description-id="create_space_description" />
|
||||
title-id="create_space_title" description-id="create_space_description"
|
||||
error-message-id="error_create_space_dialog" />
|
||||
|
||||
<dialog name="spaceDetails" page="/jsp/dialog/space-details.jsp" managed-bean="SpaceDetailsDialog"
|
||||
title="Space Details Dialog" description="Space Details Dialog Decsription"
|
||||
@@ -49,7 +50,8 @@
|
||||
icon="/images/icons/create_space_large.gif"
|
||||
actions-config-id="create-space-actions"
|
||||
title-id="advanced_space_details_title"
|
||||
description-id="advanced_space_details_description">
|
||||
description-id="advanced_space_details_description"
|
||||
error-message-id="error_create_space_wizard">
|
||||
<step name="details" title-id="starting_space">
|
||||
<page path="/jsp/wizard/new-space/create-from.jsp"
|
||||
title-id="create_space_details_title"
|
||||
|
@@ -51,13 +51,7 @@
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</f:verbatim>
|
||||
|
||||
<%-- TODO: Move this to the container page and add error-message-id attribute to dialog config --%>
|
||||
|
||||
<a:errors message="#{msg.error_wizard}" styleClass="errorMessage" />
|
||||
|
||||
<f:verbatim>
|
||||
<table cellpadding="2" cellspacing="2" border="0" width="100%">
|
||||
<tr>
|
||||
<td>1.</td>
|
||||
|
@@ -47,11 +47,7 @@
|
||||
var isIE = (document.all);
|
||||
|
||||
</script>
|
||||
</f:verbatim>
|
||||
|
||||
<a:errors message="#{msg.error_wizard}" styleClass="errorMessage" />
|
||||
|
||||
<f:verbatim>
|
||||
|
||||
<div id='editor' style='width:100%; height:360px'>
|
||||
</f:verbatim>
|
||||
<h:outputText value="#{WizardManager.bean.content}" escape="false" />
|
||||
|
@@ -19,8 +19,6 @@
|
||||
<%@ taglib uri="/WEB-INF/alfresco.tld" prefix="a" %>
|
||||
<%@ taglib uri="/WEB-INF/repo.tld" prefix="r" %>
|
||||
|
||||
<a:errors message="#{msg.error_wizard}" styleClass="errorMessage" />
|
||||
|
||||
<h:inputTextarea id="textArea" rows="24" cols="112" value="#{WizardManager.bean.content}" />
|
||||
|
||||
|
@@ -66,8 +66,6 @@
|
||||
</script>
|
||||
</f:verbatim>
|
||||
|
||||
<a:errors message="#{msg.error_wizard}" styleClass="errorMessage" />
|
||||
|
||||
<h:panelGrid columns="1" cellpadding="2" style="padding-top: 4px; padding-bottom: 4px;"
|
||||
width="100%" rowClasses="wizardSectionHeading">
|
||||
<h:outputText value=" #{msg.general_properties}" escape="false" />
|
||||
|
@@ -19,8 +19,6 @@
|
||||
<%@ taglib uri="/WEB-INF/alfresco.tld" prefix="a" %>
|
||||
<%@ taglib uri="/WEB-INF/repo.tld" prefix="r" %>
|
||||
|
||||
<a:errors message="#{msg.error_dialog}" styleClass="errorMessage" />
|
||||
|
||||
<h:panelGrid columns="1" cellpadding="2" style="padding-top: 4px; padding-bottom: 4px;"
|
||||
width="100%" rowClasses="wizardSectionHeading">
|
||||
<h:outputText value=" #{msg.properties}" escape="false" />
|
||||
|
@@ -94,6 +94,9 @@
|
||||
<table cellspacing="0" cellpadding="3" border="0" width="100%">
|
||||
<tr>
|
||||
<td width="100%" valign="top">
|
||||
|
||||
<a:errors message="#{DialogManager.errorMessage}" styleClass="errorMessage" />
|
||||
|
||||
<% PanelGenerator.generatePanelStart(out, request.getContextPath(), "white", "white"); %>
|
||||
<f:subview id="dialog-body">
|
||||
<jsp:include page="<%=Application.getDialogManager().getPage() %>" />
|
||||
|
@@ -51,13 +51,7 @@
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</f:verbatim>
|
||||
|
||||
<%-- TODO: Move this to the container page and add error-message-id attribute to dialog config --%>
|
||||
|
||||
<a:errors message="#{msg.error_wizard}" styleClass="errorMessage" />
|
||||
|
||||
<f:verbatim>
|
||||
<table cellpadding="2" cellspacing="2" border="0" width="100%">
|
||||
<tr>
|
||||
<td>1.</td>
|
||||
|
@@ -35,13 +35,7 @@
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</f:verbatim>
|
||||
|
||||
<%-- TODO: Move this to the container page and add error-message-id attribute to dialog config --%>
|
||||
|
||||
<a:errors message="#{msg.error_wizard}" styleClass="errorMessage" />
|
||||
|
||||
<f:verbatim>
|
||||
<table cellpadding="2" cellspacing="2" border="0" width="100%">
|
||||
<tr>
|
||||
<td>
|
||||
|
@@ -63,15 +63,7 @@
|
||||
}
|
||||
|
||||
</script>
|
||||
</f:verbatim>
|
||||
|
||||
<%-- Create Space Dialog Fragment --%>
|
||||
|
||||
<%-- TODO: Move this to the container page and add error-message-id attribute to dialog config --%>
|
||||
|
||||
<a:errors message="#{msg.error_create_space_dialog}" styleClass="errorMessage" />
|
||||
|
||||
<f:verbatim>
|
||||
<table cellpadding="2" cellspacing="2" border="0" width="100%">
|
||||
<tr>
|
||||
<td colspan="2" class="wizardSectionHeading">
|
||||
|
@@ -85,11 +85,7 @@
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</f:verbatim>
|
||||
|
||||
<a:errors message="#{msg.error_wizard}" styleClass="errorMessage" />
|
||||
|
||||
<f:verbatim>
|
||||
<table cellpadding="3" cellspacing="2" border="0" width="100%">
|
||||
<tr>
|
||||
<td colspan="2" class="wizardSectionHeading">
|
||||
|
@@ -20,12 +20,6 @@
|
||||
<%@ taglib uri="/WEB-INF/alfresco.tld" prefix="a" %>
|
||||
<%@ taglib uri="/WEB-INF/repo.tld" prefix="r" %>
|
||||
|
||||
<%-- Edit Space Dialog Fragment --%>
|
||||
|
||||
<%-- TODO: Move this to the container page and add error-message-id attribute to dialog config --%>
|
||||
|
||||
<a:errors message="#{msg.error_dialog}" styleClass="errorMessage" />
|
||||
|
||||
<h:panelGrid columns="1" rowClasses="wizardSectionHeading, paddingRow"
|
||||
cellpadding="2" cellspacing="2" width="100%">
|
||||
<h:outputText value="#{msg.space_props}" />
|
||||
|
@@ -98,12 +98,6 @@
|
||||
<h:outputText styleClass="mainSubTitle" value="#{msg.steps}"/><br>
|
||||
<a:modeList itemSpacing="3" iconColumnWidth="2" selectedStyleClass="statusListHighlight"
|
||||
value="#{WizardManager.currentStepAsString}" disabled="true">
|
||||
<%--
|
||||
<a:listItem value="1" label="1. #{msg.starting_space}" />
|
||||
<a:listItem value="2" label="2. #{msg.space_options}" />
|
||||
<a:listItem value="3" label="3. #{msg.space_details}" />
|
||||
<a:listItem value="4" label="4. #{msg.summary}" />
|
||||
--%>
|
||||
<a:listItems value="#{WizardManager.stepItems}" />
|
||||
</a:modeList>
|
||||
<% PanelGenerator.generatePanelEnd(out, request.getContextPath(), "blue"); %>
|
||||
@@ -111,10 +105,7 @@
|
||||
|
||||
<td width="100%" valign="top">
|
||||
|
||||
<%-- Externalise the error message into an error-message-id attribute on the wizard config --%>
|
||||
<%--
|
||||
<a:errors message="#{msg.error_wizard}" styleClass="errorMessage" />
|
||||
--%>
|
||||
<a:errors message="#{WizardManager.errorMessage}" styleClass="errorMessage" />
|
||||
|
||||
<% PanelGenerator.generatePanelStart(out, request.getContextPath(), "white", "white"); %>
|
||||
<table cellpadding="2" cellspacing="2" border="0" width="100%">
|
||||
|
Reference in New Issue
Block a user