From a77bc51bac3d3f5c6f5c25593da85a9f0efbdddd Mon Sep 17 00:00:00 2001 From: Gavin Cornwell Date: Tue, 23 May 2006 14:39:51 +0000 Subject: [PATCH] Fix for AWC-656 & 695 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2956 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../content/EditContentPropertiesDialog.java | 6 +++ .../generator/BaseComponentGenerator.java | 38 +++++++++++++------ .../web/bean/spaces/EditSpaceDialog.java | 6 +++ 3 files changed, 39 insertions(+), 11 deletions(-) diff --git a/source/java/org/alfresco/web/bean/content/EditContentPropertiesDialog.java b/source/java/org/alfresco/web/bean/content/EditContentPropertiesDialog.java index 13f864b46c..04cc367d9b 100644 --- a/source/java/org/alfresco/web/bean/content/EditContentPropertiesDialog.java +++ b/source/java/org/alfresco/web/bean/content/EditContentPropertiesDialog.java @@ -227,6 +227,12 @@ public class EditContentPropertiesDialog extends BaseDialogBean } } + @Override + public boolean getFinishButtonDisabled() + { + return false; + } + // ------------------------------------------------------------------------------ // Bean getters and setters diff --git a/source/java/org/alfresco/web/bean/generator/BaseComponentGenerator.java b/source/java/org/alfresco/web/bean/generator/BaseComponentGenerator.java index 123bd4f8c9..8137ec929b 100644 --- a/source/java/org/alfresco/web/bean/generator/BaseComponentGenerator.java +++ b/source/java/org/alfresco/web/bean/generator/BaseComponentGenerator.java @@ -35,6 +35,7 @@ import org.alfresco.web.ui.repo.component.property.UIPropertySheet; import org.alfresco.web.ui.repo.component.property.UIPropertySheet.ClientValidation; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.springframework.util.StringUtils; import org.springframework.web.jsf.FacesContextUtils; public abstract class BaseComponentGenerator implements IComponentGenerator @@ -398,7 +399,8 @@ public abstract class BaseComponentGenerator implements IComponentGenerator // add the validation failed message to show (use the value of the // label component of the given item) String msg = Application.getMessage(context, "validation_mandatory"); - params.add("'" + MessageFormat.format(msg, new Object[] {item.getResolvedDisplayLabel()}) + "'"); + addStringConstraintParam(params, + MessageFormat.format(msg, new Object[] {item.getResolvedDisplayLabel()})); // add the validation case to the property sheet propertySheet.addClientValidation(new ClientValidation("validateMandatory", @@ -504,12 +506,12 @@ public abstract class BaseComponentGenerator implements IComponentGenerator try { // encode the expression so it can be unescaped by JavaScript - params.add("'" + URLEncoder.encode(expression, "UTF-8") + "'"); + addStringConstraintParam(params, URLEncoder.encode(expression, "UTF-8")); } catch (UnsupportedEncodingException e) { // just add the expression as is - params.add("'" + expression + "'"); + addStringConstraintParam(params, expression); } // add the requiresMatch parameter @@ -517,12 +519,12 @@ public abstract class BaseComponentGenerator implements IComponentGenerator // add the validation failed messages String matchMsg = Application.getMessage(context, "validation_regex"); - params.add("'" + MessageFormat.format(matchMsg, new Object[] - {property.getResolvedDisplayLabel()}) + "'"); + addStringConstraintParam(params, + MessageFormat.format(matchMsg, new Object[] {property.getResolvedDisplayLabel()})); String noMatchMsg = Application.getMessage(context, "validation_regex_not_match"); - params.add("'" + MessageFormat.format(noMatchMsg, new Object[] - {property.getResolvedDisplayLabel()}) + "'"); + addStringConstraintParam(params, + MessageFormat.format(noMatchMsg, new Object[] {property.getResolvedDisplayLabel()})); // add the validation case to the property sheet propertySheet.addClientValidation(new ClientValidation("validateRegex", @@ -562,8 +564,8 @@ public abstract class BaseComponentGenerator implements IComponentGenerator // add the validation failed message to show String msg = Application.getMessage(context, "validation_string_length"); - params.add("'" + MessageFormat.format(msg, new Object[] - {property.getResolvedDisplayLabel(), min, max}) + "'"); + addStringConstraintParam(params, + MessageFormat.format(msg, new Object[] {property.getResolvedDisplayLabel(), min, max})); // add the validation case to the property sheet propertySheet.addClientValidation(new ClientValidation("validateStringLength", @@ -603,8 +605,8 @@ public abstract class BaseComponentGenerator implements IComponentGenerator // add the validation failed message to show String msg = Application.getMessage(context, "validation_numeric_range"); - params.add("'" + MessageFormat.format(msg, new Object[] - {property.getResolvedDisplayLabel(), min, max}) + "'"); + addStringConstraintParam(params, + MessageFormat.format(msg, new Object[] {property.getResolvedDisplayLabel(), min, max})); // add the validation case to the property sheet propertySheet.addClientValidation(new ClientValidation("validateNumberRange", @@ -695,6 +697,20 @@ public abstract class BaseComponentGenerator implements IComponentGenerator return getDataDictionary(context).getAssociationDefinition(node, associationName); } + /** + * Adds the given string parameter to the list of parameters to be used for + * validating constraints on the client. + * This method adds the quotes around the given parameter and also escapes + * any ocurrences of the double quote character. + * + * @param params The list of parameters for the constraint + * @param param The string parameter to add + */ + protected void addStringConstraintParam(List params, String param) + { + params.add("\"" + StringUtils.replace(param, "\"", "\\\"") + "\""); + } + private DataDictionary getDataDictionary(FacesContext context) { if (this.dataDictionary == null) diff --git a/source/java/org/alfresco/web/bean/spaces/EditSpaceDialog.java b/source/java/org/alfresco/web/bean/spaces/EditSpaceDialog.java index 048c132ba3..d95da6cffb 100644 --- a/source/java/org/alfresco/web/bean/spaces/EditSpaceDialog.java +++ b/source/java/org/alfresco/web/bean/spaces/EditSpaceDialog.java @@ -41,6 +41,12 @@ public class EditSpaceDialog extends CreateSpaceDialog return Application.getMessage(FacesContext.getCurrentInstance(), "ok"); } + @Override + public boolean getFinishButtonDisabled() + { + return false; + } + /** * Returns the editable node *