- 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:
Gavin Cornwell
2006-05-12 12:40:16 +00:00
parent af93c5f1af
commit 02cb2ac1e7
22 changed files with 76 additions and 66 deletions

View File

@@ -8,7 +8,7 @@
<!-- Definition of the create space dialog --> <!-- Definition of the create space dialog -->
<dialog name="createSpace" page="/jsp/spaces/create-space-dialog.jsp" managed-bean="CreateSpaceDialog" <dialog name="createSpace" page="/jsp/spaces/create-space-dialog.jsp" managed-bean="CreateSpaceDialog"
icon="/images/icons/create_space_large.gif" title-id="create_space" 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 --> <!-- Definition of the edit space dialog -->
<dialog name="editSpace" page="/jsp/spaces/edit-space-dialog.jsp" managed-bean="EditSpaceDialog" <dialog name="editSpace" page="/jsp/spaces/edit-space-dialog.jsp" managed-bean="EditSpaceDialog"

View File

@@ -90,6 +90,9 @@ public abstract class BaseDialogBean implements IDialogBean
} }
catch (Throwable e) catch (Throwable e)
{ {
// reset the flag so we can re-attempt the operation
isFinished = false;
// rollback the transaction // rollback the transaction
try { if (tx != null) {tx.rollback();} } catch (Exception ex) {} try { if (tx != null) {tx.rollback();} } catch (Exception ex) {}
Utils.addErrorMessage(formatErrorMessage(e)); Utils.addErrorMessage(formatErrorMessage(e));

View File

@@ -94,6 +94,17 @@ public class DialogManager
return this.currentDialogConfig.getIcon(); 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 * Returns the resolved title to use for the dialog
* *

View File

@@ -115,6 +115,17 @@ public class WizardManager
return this.currentWizardConfig.getIcon(); 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 * Returns the resolved title to use for the wizard
* *

View File

@@ -130,11 +130,13 @@ public class DialogsConfigElement extends ConfigElementAdapter
protected String titleId; protected String titleId;
protected String description; protected String description;
protected String descriptionId; protected String descriptionId;
protected String errorMsgId = "error_dialog";
public DialogConfig(String name, String page, String bean, public DialogConfig(String name, String page, String bean,
String actionsConfigId, String icon, String actionsConfigId, String icon,
String title, String titleId, String title, String titleId,
String description, String descriptionId) String description, String descriptionId,
String errorMsgId)
{ {
// check the mandatory parameters are present // check the mandatory parameters are present
ParameterCheck.mandatoryString("name", name); ParameterCheck.mandatoryString("name", name);
@@ -150,6 +152,11 @@ public class DialogsConfigElement extends ConfigElementAdapter
this.titleId = titleId; this.titleId = titleId;
this.description = description; this.description = description;
this.descriptionId = descriptionId; this.descriptionId = descriptionId;
if (errorMsgId != null && errorMsgId.length() > 0)
{
this.errorMsgId = errorMsgId;
}
} }
public String getDescription() public String getDescription()
@@ -197,6 +204,11 @@ public class DialogsConfigElement extends ConfigElementAdapter
return this.titleId; return this.titleId;
} }
public String getErrorMessageId()
{
return this.errorMsgId;
}
/** /**
* @see java.lang.Object#toString() * @see java.lang.Object#toString()
*/ */
@@ -212,7 +224,8 @@ public class DialogsConfigElement extends ConfigElementAdapter
buffer.append(" title=").append(this.title); buffer.append(" title=").append(this.title);
buffer.append(" titleId=").append(this.titleId); buffer.append(" titleId=").append(this.titleId);
buffer.append(" description=").append(this.description); 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(); return buffer.toString();
} }
} }

View File

@@ -41,6 +41,7 @@ public class DialogsElementReader implements ConfigElementReader
public static final String ATTR_TITLE_ID = "title-id"; public static final String ATTR_TITLE_ID = "title-id";
public static final String ATTR_DESCRIPTION = "description"; public static final String ATTR_DESCRIPTION = "description";
public static final String ATTR_DESCRIPTION_ID = "description-id"; 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) * @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 titleId = item.attributeValue(ATTR_TITLE_ID);
String description = item.attributeValue(ATTR_DESCRIPTION); String description = item.attributeValue(ATTR_DESCRIPTION);
String descriptionId = item.attributeValue(ATTR_DESCRIPTION_ID); String descriptionId = item.attributeValue(ATTR_DESCRIPTION_ID);
String errorMsgId = item.attributeValue(ATTR_ERROR_MSG_ID);
DialogsConfigElement.DialogConfig cfg = new DialogsConfigElement.DialogConfig( DialogsConfigElement.DialogConfig cfg = new DialogsConfigElement.DialogConfig(
name, page, bean, actions, icon, title, titleId, description, name, page, bean, actions, icon, title, titleId, description,
descriptionId); descriptionId, errorMsgId);
configElement.addDialog(cfg); configElement.addDialog(cfg);
} }

View File

@@ -656,6 +656,7 @@ public class WebClientConfigTest extends BaseTest
assertEquals("icon", "/images/icons/create_space_large.gif", dialog.getIcon()); assertEquals("icon", "/images/icons/create_space_large.gif", dialog.getIcon());
assertEquals("title-id", "create_space_title", dialog.getTitleId()); assertEquals("title-id", "create_space_title", dialog.getTitleId());
assertEquals("description-id", "create_space_description", dialog.getDescriptionId()); 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("title should be null", dialog.getTitle());
assertNull("description should be null", dialog.getDescription()); 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("icon", "/images/icons/create_space_large.gif", dialog.getIcon());
assertEquals("title", "Space Details Dialog", dialog.getTitle()); assertEquals("title", "Space Details Dialog", dialog.getTitle());
assertEquals("description", "Space Details Dialog Decsription", dialog.getDescription()); 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("title-id should be null", dialog.getTitleId());
assertNull("description-id should be null", dialog.getDescriptionId()); 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("icon", "/images/icons/example-logo.gif", wizard.getIcon());
assertEquals("title", "Example Wizard Title", wizard.getTitle()); assertEquals("title", "Example Wizard Title", wizard.getTitle());
assertEquals("description", "Example Wizard Description", wizard.getDescription()); assertEquals("description", "Example Wizard Description", wizard.getDescription());
assertEquals("error-message-id", "error_wizard", wizard.getErrorMessageId());
assertNull("title-id should be null", wizard.getTitleId()); assertNull("title-id should be null", wizard.getTitleId());
assertNull("description-id should be null", wizard.getDescriptionId()); 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("icon", "/images/icons/create_space_large.gif", wizard.getIcon());
assertEquals("title-id", "advanced_space_details_title", wizard.getTitleId()); assertEquals("title-id", "advanced_space_details_title", wizard.getTitleId());
assertEquals("description-id", "advanced_space_details_description", wizard.getDescriptionId()); 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("title should be null", wizard.getTitle());
assertNull("description should be null", wizard.getDescription()); assertNull("description should be null", wizard.getDescription());
List<StepConfig> steps = wizard.getStepsAsList(); List<StepConfig> steps = wizard.getStepsAsList();

View File

@@ -160,12 +160,15 @@ public class WizardsConfigElement extends ConfigElementAdapter
protected String managedBean; protected String managedBean;
protected String icon; protected String icon;
protected String actionsConfigId; protected String actionsConfigId;
protected String errorMsgId = "error_wizard";
protected Map<String, StepConfig> steps = new LinkedHashMap<String, StepConfig>(4); protected Map<String, StepConfig> steps = new LinkedHashMap<String, StepConfig>(4);
public WizardConfig(String name, String bean, public WizardConfig(String name, String bean,
String actionsConfigId, String icon, String actionsConfigId, String icon,
String title, String titleId, String title, String titleId,
String description, String descriptionId) String description, String descriptionId,
String errorMsgId)
{ {
super(title, titleId, description, descriptionId); super(title, titleId, description, descriptionId);
@@ -176,6 +179,11 @@ public class WizardsConfigElement extends ConfigElementAdapter
this.managedBean = bean; this.managedBean = bean;
this.icon = icon; this.icon = icon;
this.actionsConfigId = actionsConfigId; this.actionsConfigId = actionsConfigId;
if (errorMsgId != null && errorMsgId.length() > 0)
{
this.errorMsgId = errorMsgId;
}
} }
public String getName() public String getName()
@@ -198,6 +206,11 @@ public class WizardsConfigElement extends ConfigElementAdapter
return this.actionsConfigId; return this.actionsConfigId;
} }
public String getErrorMessageId()
{
return this.errorMsgId;
}
public int getNumberSteps() public int getNumberSteps()
{ {
return this.steps.size(); return this.steps.size();
@@ -244,7 +257,8 @@ public class WizardsConfigElement extends ConfigElementAdapter
buffer.append(" title=").append(this.title); buffer.append(" title=").append(this.title);
buffer.append(" titleId=").append(this.titleId); buffer.append(" titleId=").append(this.titleId);
buffer.append(" description=").append(this.description); 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(); return buffer.toString();
} }
} }

View File

@@ -49,6 +49,7 @@ public class WizardsElementReader implements ConfigElementReader
public static final String ATTR_DESCRIPTION_ID = "description-id"; public static final String ATTR_DESCRIPTION_ID = "description-id";
public static final String ATTR_INSTRUCTION = "instruction"; public static final String ATTR_INSTRUCTION = "instruction";
public static final String ATTR_INSTRUCTION_ID = "instruction-id"; 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_IF = "if";
public static final String ATTR_PATH = "path"; public static final String ATTR_PATH = "path";
@@ -85,10 +86,11 @@ public class WizardsElementReader implements ConfigElementReader
String titleId = wizard.attributeValue(ATTR_TITLE_ID); String titleId = wizard.attributeValue(ATTR_TITLE_ID);
String description = wizard.attributeValue(ATTR_DESCRIPTION); String description = wizard.attributeValue(ATTR_DESCRIPTION);
String descriptionId = wizard.attributeValue(ATTR_DESCRIPTION_ID); String descriptionId = wizard.attributeValue(ATTR_DESCRIPTION_ID);
String errorMsgId = wizard.attributeValue(ATTR_ERROR_MSG_ID);
// create the wizard config object // create the wizard config object
WizardsConfigElement.WizardConfig wizardCfg = new WizardsConfigElement.WizardConfig( 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); Iterator<Element> steps = wizard.elementIterator(ELEMENT_STEP);
while (steps.hasNext()) while (steps.hasNext())

View File

@@ -13,7 +13,8 @@
<dialogs> <dialogs>
<dialog name="createSpace" page="/jsp/dialog/create-space.jsp" managed-bean="NewSpaceDialog" <dialog name="createSpace" page="/jsp/dialog/create-space.jsp" managed-bean="NewSpaceDialog"
actions-config-id="space-actions" icon="/images/icons/create_space_large.gif" 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" <dialog name="spaceDetails" page="/jsp/dialog/space-details.jsp" managed-bean="SpaceDetailsDialog"
title="Space Details Dialog" description="Space Details Dialog Decsription" title="Space Details Dialog" description="Space Details Dialog Decsription"
@@ -49,7 +50,8 @@
icon="/images/icons/create_space_large.gif" icon="/images/icons/create_space_large.gif"
actions-config-id="create-space-actions" actions-config-id="create-space-actions"
title-id="advanced_space_details_title" 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"> <step name="details" title-id="starting_space">
<page path="/jsp/wizard/new-space/create-from.jsp" <page path="/jsp/wizard/new-space/create-from.jsp"
title-id="create_space_details_title" title-id="create_space_details_title"

View File

@@ -51,13 +51,7 @@
} }
} }
</script> </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%"> <table cellpadding="2" cellspacing="2" border="0" width="100%">
<tr> <tr>
<td>1.</td> <td>1.</td>

View File

@@ -47,11 +47,7 @@
var isIE = (document.all); var isIE = (document.all);
</script> </script>
</f:verbatim>
<a:errors message="#{msg.error_wizard}" styleClass="errorMessage" />
<f:verbatim>
<div id='editor' style='width:100%; height:360px'> <div id='editor' style='width:100%; height:360px'>
</f:verbatim> </f:verbatim>
<h:outputText value="#{WizardManager.bean.content}" escape="false" /> <h:outputText value="#{WizardManager.bean.content}" escape="false" />

View File

@@ -19,8 +19,6 @@
<%@ taglib uri="/WEB-INF/alfresco.tld" prefix="a" %> <%@ taglib uri="/WEB-INF/alfresco.tld" prefix="a" %>
<%@ taglib uri="/WEB-INF/repo.tld" prefix="r" %> <%@ 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}" /> <h:inputTextarea id="textArea" rows="24" cols="112" value="#{WizardManager.bean.content}" />

View File

@@ -66,8 +66,6 @@
</script> </script>
</f:verbatim> </f:verbatim>
<a:errors message="#{msg.error_wizard}" styleClass="errorMessage" />
<h:panelGrid columns="1" cellpadding="2" style="padding-top: 4px; padding-bottom: 4px;" <h:panelGrid columns="1" cellpadding="2" style="padding-top: 4px; padding-bottom: 4px;"
width="100%" rowClasses="wizardSectionHeading"> width="100%" rowClasses="wizardSectionHeading">
<h:outputText value="&nbsp;#{msg.general_properties}" escape="false" /> <h:outputText value="&nbsp;#{msg.general_properties}" escape="false" />

View File

@@ -19,8 +19,6 @@
<%@ taglib uri="/WEB-INF/alfresco.tld" prefix="a" %> <%@ taglib uri="/WEB-INF/alfresco.tld" prefix="a" %>
<%@ taglib uri="/WEB-INF/repo.tld" prefix="r" %> <%@ 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;" <h:panelGrid columns="1" cellpadding="2" style="padding-top: 4px; padding-bottom: 4px;"
width="100%" rowClasses="wizardSectionHeading"> width="100%" rowClasses="wizardSectionHeading">
<h:outputText value="&nbsp;#{msg.properties}" escape="false" /> <h:outputText value="&nbsp;#{msg.properties}" escape="false" />

View File

@@ -94,6 +94,9 @@
<table cellspacing="0" cellpadding="3" border="0" width="100%"> <table cellspacing="0" cellpadding="3" border="0" width="100%">
<tr> <tr>
<td width="100%" valign="top"> <td width="100%" valign="top">
<a:errors message="#{DialogManager.errorMessage}" styleClass="errorMessage" />
<% PanelGenerator.generatePanelStart(out, request.getContextPath(), "white", "white"); %> <% PanelGenerator.generatePanelStart(out, request.getContextPath(), "white", "white"); %>
<f:subview id="dialog-body"> <f:subview id="dialog-body">
<jsp:include page="<%=Application.getDialogManager().getPage() %>" /> <jsp:include page="<%=Application.getDialogManager().getPage() %>" />

View File

@@ -51,13 +51,7 @@
} }
} }
</script> </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%"> <table cellpadding="2" cellspacing="2" border="0" width="100%">
<tr> <tr>
<td>1.</td> <td>1.</td>

View File

@@ -35,13 +35,7 @@
} }
} }
</script> </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%"> <table cellpadding="2" cellspacing="2" border="0" width="100%">
<tr> <tr>
<td> <td>

View File

@@ -63,15 +63,7 @@
} }
</script> </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%"> <table cellpadding="2" cellspacing="2" border="0" width="100%">
<tr> <tr>
<td colspan="2" class="wizardSectionHeading"> <td colspan="2" class="wizardSectionHeading">

View File

@@ -85,11 +85,7 @@
} }
} }
</script> </script>
</f:verbatim>
<a:errors message="#{msg.error_wizard}" styleClass="errorMessage" />
<f:verbatim>
<table cellpadding="3" cellspacing="2" border="0" width="100%"> <table cellpadding="3" cellspacing="2" border="0" width="100%">
<tr> <tr>
<td colspan="2" class="wizardSectionHeading"> <td colspan="2" class="wizardSectionHeading">

View File

@@ -20,12 +20,6 @@
<%@ taglib uri="/WEB-INF/alfresco.tld" prefix="a" %> <%@ taglib uri="/WEB-INF/alfresco.tld" prefix="a" %>
<%@ taglib uri="/WEB-INF/repo.tld" prefix="r" %> <%@ 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" <h:panelGrid columns="1" rowClasses="wizardSectionHeading, paddingRow"
cellpadding="2" cellspacing="2" width="100%"> cellpadding="2" cellspacing="2" width="100%">
<h:outputText value="#{msg.space_props}" /> <h:outputText value="#{msg.space_props}" />

View File

@@ -98,12 +98,6 @@
<h:outputText styleClass="mainSubTitle" value="#{msg.steps}"/><br> <h:outputText styleClass="mainSubTitle" value="#{msg.steps}"/><br>
<a:modeList itemSpacing="3" iconColumnWidth="2" selectedStyleClass="statusListHighlight" <a:modeList itemSpacing="3" iconColumnWidth="2" selectedStyleClass="statusListHighlight"
value="#{WizardManager.currentStepAsString}" disabled="true"> 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:listItems value="#{WizardManager.stepItems}" />
</a:modeList> </a:modeList>
<% PanelGenerator.generatePanelEnd(out, request.getContextPath(), "blue"); %> <% PanelGenerator.generatePanelEnd(out, request.getContextPath(), "blue"); %>
@@ -111,10 +105,7 @@
<td width="100%" valign="top"> <td width="100%" valign="top">
<%-- Externalise the error message into an error-message-id attribute on the wizard config --%> <a:errors message="#{WizardManager.errorMessage}" styleClass="errorMessage" />
<%--
<a:errors message="#{msg.error_wizard}" styleClass="errorMessage" />
--%>
<% PanelGenerator.generatePanelStart(out, request.getContextPath(), "white", "white"); %> <% PanelGenerator.generatePanelStart(out, request.getContextPath(), "white", "white"); %>
<table cellpadding="2" cellspacing="2" border="0" width="100%"> <table cellpadding="2" cellspacing="2" border="0" width="100%">