From e29e24e7616f15887787d0e15ba1be63ca6c999c Mon Sep 17 00:00:00 2001 From: Derek Hulley Date: Tue, 26 Jun 2007 21:48:19 +0000 Subject: [PATCH] Partial fix for AWC-999: Content upload guesses character encoding and offers the user the chance to change it. TODO: Fix the "Modify Content Properties" to include the encoding as a changeable option. Modified other entry points of content into the system. All calls to ContentWriter.setEncoding("UTF-8") need some serious examination. It is no longer necessary to assume anything about the encoding. The worst case scenario is that we guess the encoding from the stream without giving the user the chance to change it. This works for most non-interactive scenarios like CIFS, WebDAV and FTP, now. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6113 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- config/alfresco/messages/webclient.properties | 2 + .../web/app/servlet/UploadContentServlet.java | 23 +++-- .../web/bean/ajax/FileUploadBean.java | 29 +++++- .../web/bean/content/AddContentDialog.java | 30 +++++- .../web/bean/content/BaseContentWizard.java | 34 ++++++- .../generator/CharsetSelectorGenerator.java | 81 ++++++++++++++++ .../web/bean/repository/Repository.java | 18 ++++ .../web/bean/wcm/AddAvmContentDialog.java | 3 +- .../ui/repo/component/UICharsetSelector.java | 87 +++++++++++++++++ .../ui/repo/converter/CharsetConverter.java | 79 +++++++++++++++ .../ui/repo/converter/MimeTypeConverter.java | 2 +- .../web/ui/repo/tag/CharsetSelectorTag.java | 96 +++++++++++++++++++ source/web/WEB-INF/faces-config-repo.xml | 5 + source/web/WEB-INF/repo.tld | 36 +++++++ source/web/jsp/content/add-content-dialog.jsp | 11 +++ source/web/jsp/wcm/add-content-dialog.jsp | 9 ++ 16 files changed, 528 insertions(+), 17 deletions(-) create mode 100644 source/java/org/alfresco/web/bean/generator/CharsetSelectorGenerator.java create mode 100644 source/java/org/alfresco/web/ui/repo/component/UICharsetSelector.java create mode 100644 source/java/org/alfresco/web/ui/repo/converter/CharsetConverter.java create mode 100644 source/java/org/alfresco/web/ui/repo/tag/CharsetSelectorTag.java diff --git a/config/alfresco/messages/webclient.properties b/config/alfresco/messages/webclient.properties index 027d6cb9fd..e1574a53cc 100644 --- a/config/alfresco/messages/webclient.properties +++ b/config/alfresco/messages/webclient.properties @@ -232,6 +232,7 @@ other_action=Run Action information=Information move=Move type=Type +encoding=Encoding aspect=Aspect workflow=Workflow workflows=Workflows @@ -1646,6 +1647,7 @@ error_save_search=Failed to save search due to error: {0} error_restore_search=Failed to restore saved search due to error: {0} error_shortcut_permissions=Unable to navigate to the item as it cannot be read by this user. Another user may have modified the permission. error_association=Failed to find association definition for association \"{0}\". +error_charset_null=Null characterset value # Confirmations return_to_application=Return to application diff --git a/source/java/org/alfresco/web/app/servlet/UploadContentServlet.java b/source/java/org/alfresco/web/app/servlet/UploadContentServlet.java index 240b2c01eb..014718246f 100644 --- a/source/java/org/alfresco/web/app/servlet/UploadContentServlet.java +++ b/source/java/org/alfresco/web/app/servlet/UploadContentServlet.java @@ -25,6 +25,8 @@ package org.alfresco.web.app.servlet; import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.Charset; import java.util.StringTokenizer; import javax.servlet.ServletException; @@ -32,6 +34,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.alfresco.model.ContentModel; +import org.alfresco.repo.content.encoding.ContentCharsetFinder; import org.alfresco.service.ServiceRegistry; import org.alfresco.service.cmr.repository.ContentService; import org.alfresco.service.cmr.repository.ContentWriter; @@ -155,17 +158,13 @@ public class UploadContentServlet extends BaseServlet return; } - // Get the encoding - String encoding = req.getParameter(ARG_ENCODING); - if (encoding == null || encoding.length() == 0) - { - encoding = "UTF-8"; - } - // get the services we need to retrieve the content ServiceRegistry serviceRegistry = getServiceRegistry(getServletContext()); ContentService contentService = serviceRegistry.getContentService(); PermissionService permissionService = serviceRegistry.getPermissionService(); + MimetypeService mimetypeService = serviceRegistry.getMimetypeService(); + + InputStream inputStream = req.getInputStream(); // Sort out the mimetype String mimetype = req.getParameter(ARG_MIMETYPE); @@ -188,6 +187,16 @@ public class UploadContentServlet extends BaseServlet } } + // Get the encoding + String encoding = req.getParameter(ARG_ENCODING); + if (encoding == null || encoding.length() == 0) + { + // Get the encoding + ContentCharsetFinder charsetFinder = mimetypeService.getContentCharsetFinder(); + Charset charset = charsetFinder.getCharset(inputStream, mimetype); + encoding = charset.name(); + } + if (logger.isDebugEnabled()) { if (nodeRef != null) {logger.debug("Found NodeRef: " + nodeRef.toString());} diff --git a/source/java/org/alfresco/web/bean/ajax/FileUploadBean.java b/source/java/org/alfresco/web/bean/ajax/FileUploadBean.java index bd224f866b..2e3d5a5a46 100644 --- a/source/java/org/alfresco/web/bean/ajax/FileUploadBean.java +++ b/source/java/org/alfresco/web/bean/ajax/FileUploadBean.java @@ -25,6 +25,8 @@ package org.alfresco.web.bean.ajax; import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; import java.io.Serializable; import java.net.URLDecoder; import java.util.HashMap; @@ -125,8 +127,31 @@ public class FileUploadBean NodeRef containerRef = pathToNodeRef(fc, currentPath); if (containerRef != null) { - // Try and extract metadata from the file + // Guess the mimetype String mimetype = Repository.getMimeTypeForFileName(fc, filename); + + // Now guess the encoding + String encoding = "UTF-8"; + InputStream is = null; + try + { + is = new FileInputStream(file); + encoding = Repository.guessEncoding(fc, is, mimetype); + } + catch (Throwable e) + { + // Bad as it is, it's not terminal + logger.error("Failed to guess character encoding of file: " + file, e); + } + finally + { + if (is != null) + { + try { is.close(); } catch (Throwable e) {} + } + } + + // Try and extract metadata from the file ContentReader cr = new FileContentReader(file); cr.setMimetype(mimetype); @@ -170,7 +195,7 @@ public class FileUploadBean // get a writer for the content and put the file ContentWriter writer = services.getContentService().getWriter(fileNodeRef, ContentModel.PROP_CONTENT, true); writer.setMimetype(mimetype); - writer.setEncoding("UTF-8"); + writer.setEncoding(encoding); writer.putContent(file); } } diff --git a/source/java/org/alfresco/web/bean/content/AddContentDialog.java b/source/java/org/alfresco/web/bean/content/AddContentDialog.java index 179a4754ae..40c11a8732 100644 --- a/source/java/org/alfresco/web/bean/content/AddContentDialog.java +++ b/source/java/org/alfresco/web/bean/content/AddContentDialog.java @@ -24,7 +24,10 @@ */ package org.alfresco.web.bean.content; +import java.io.BufferedInputStream; import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; import java.io.Serializable; import java.text.MessageFormat; import java.util.ArrayList; @@ -68,6 +71,7 @@ public class AddContentDialog extends BaseContentWizard // Try and extract metadata from the file ContentReader cr = new FileContentReader(this.file); cr.setMimetype(this.mimeType); + cr.setEncoding(this.encoding); // create properties for content type Map contentProps = new HashMap(5, 1.0f); @@ -148,9 +152,29 @@ public class AddContentDialog extends BaseContentWizard // NOTE: This is a far from ideal solution but will do until we have // a pure JSF upload solution working. This method is only called // after a file is uploaded, so we can calculate the mime type and - // determine whether to enable inline editing in here. - this.mimeType = Repository.getMimeTypeForFileName( - FacesContext.getCurrentInstance(), this.fileName); + // determine whether to enable inline editing in here. + FacesContext fc = FacesContext.getCurrentInstance(); + this.mimeType = Repository.getMimeTypeForFileName(fc, this.fileName); + this.encoding = "UTF-8"; + InputStream is = null; + try + { + if (this.file != null) + { + is = new BufferedInputStream(new FileInputStream(this.file)); + this.encoding = Repository.guessEncoding(fc, is, this.mimeType); + } + } + catch (Throwable e) + { + // Not terminal + logger.error("Failed to get encoding from file: " + this.fileName, e); + } + finally + { + try { is.close(); } catch (Throwable e) {} // Includes NPE + } + this.inlineEdit = (this.mimeType.equals(MimetypeMap.MIMETYPE_HTML)); // get the file upload message diff --git a/source/java/org/alfresco/web/bean/content/BaseContentWizard.java b/source/java/org/alfresco/web/bean/content/BaseContentWizard.java index ee363f511a..a2ee002e96 100644 --- a/source/java/org/alfresco/web/bean/content/BaseContentWizard.java +++ b/source/java/org/alfresco/web/bean/content/BaseContentWizard.java @@ -26,6 +26,7 @@ package org.alfresco.web.bean.content; import java.io.File; import java.io.Serializable; +import java.nio.charset.Charset; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -68,6 +69,7 @@ public abstract class BaseContentWizard extends BaseWizardBean protected String title; protected String description; protected String mimeType; + protected String encoding; protected String objectType; protected boolean inlineEdit; protected boolean otherPropertiesChoiceVisible = true; @@ -159,7 +161,23 @@ public abstract class BaseContentWizard extends BaseWizardBean { this.mimeType = mimeType; } - + + /** + * @return Returns the encoding currently selected + */ + public String getEncoding() + { + return encoding; + } + + /** + * @param encoding the document's encoding + */ + public void setEncoding(String encoding) + { + this.encoding = encoding; + } + /** * @return Returns the object type currenty selected */ @@ -250,6 +268,18 @@ public abstract class BaseContentWizard extends BaseWizardBean this.showOtherProperties = showOthers; } + public List getEncodings() + { + Map availableCharsets = Charset.availableCharsets(); + List items = new ArrayList(availableCharsets.size()); + for (Charset charset : availableCharsets.values()) + { + SelectItem item = new SelectItem(charset.name(), charset.displayName()); + items.add(item); + } + return items; + } + /** * @return Returns a list of object types to allow the user to select from */ @@ -407,7 +437,7 @@ public abstract class BaseContentWizard extends BaseWizardBean ContentWriter writer = contentService.getWriter(fileNodeRef, ContentModel.PROP_CONTENT, true); // set the mimetype and encoding writer.setMimetype(this.mimeType); - writer.setEncoding("UTF-8"); + writer.setEncoding(this.encoding); if (fileContent != null) { writer.putContent(fileContent); diff --git a/source/java/org/alfresco/web/bean/generator/CharsetSelectorGenerator.java b/source/java/org/alfresco/web/bean/generator/CharsetSelectorGenerator.java new file mode 100644 index 0000000000..39a0548543 --- /dev/null +++ b/source/java/org/alfresco/web/bean/generator/CharsetSelectorGenerator.java @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2005-2007 Alfresco Software Limited. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + * As a special exception to the terms and conditions of version 2.0 of + * the GPL, you may redistribute this Program in connection with Free/Libre + * and Open Source Software ("FLOSS") applications as described in Alfresco's + * FLOSS exception. You should have recieved a copy of the text describing + * the FLOSS exception, and it is also available here: + * http://www.alfresco.com/legal/licensing" + */ +package org.alfresco.web.bean.generator; + +import javax.faces.component.UIComponent; +import javax.faces.context.FacesContext; + +import org.alfresco.service.cmr.dictionary.PropertyDefinition; +import org.alfresco.web.app.servlet.FacesHelper; +import org.alfresco.web.ui.repo.component.UICharsetSelector; +import org.alfresco.web.ui.repo.component.property.PropertySheetItem; +import org.alfresco.web.ui.repo.component.property.UIPropertySheet; +import org.alfresco.web.ui.repo.converter.CharsetConverter; + +/** + * Generates a Charset selector component. + * + * @since 2.1 + * @author Derek Hulley + */ +public class CharsetSelectorGenerator extends BaseComponentGenerator +{ + public UIComponent generate(FacesContext context, String id) + { + UIComponent component = context.getApplication().createComponent(UICharsetSelector.COMPONENT_TYPE); + FacesHelper.setupComponentId(context, component, id); + + return component; + } + + @Override + protected void setupConverter(FacesContext context, + UIPropertySheet propertySheet, PropertySheetItem property, + PropertyDefinition propertyDef, UIComponent component) + { + if (propertySheet.inEditMode() == false) + { + if (property.getConverter() != null) + { + // create and add the custom converter + createAndSetConverter(context, property.getConverter(), component); + } + else + { + // if there isn't a custom converter add the mime type converter as a default + createAndSetConverter(context, CharsetConverter.CONVERTER_ID, component); + } + } + } + + @Override + protected void setupMandatoryValidation(FacesContext context, + UIPropertySheet propertySheet, PropertySheetItem item, + UIComponent component, boolean realTimeChecking, String idSuffix) + { + // a mime type selector will always have one value or another + // so there is no need to create a mandatory validation rule. + } +} diff --git a/source/java/org/alfresco/web/bean/repository/Repository.java b/source/java/org/alfresco/web/bean/repository/Repository.java index 56a94bccb6..17e95643f0 100644 --- a/source/java/org/alfresco/web/bean/repository/Repository.java +++ b/source/java/org/alfresco/web/bean/repository/Repository.java @@ -22,7 +22,9 @@ * http://www.alfresco.com/legal/licensing" */ package org.alfresco.web.bean.repository; +import java.io.InputStream; import java.io.Serializable; +import java.nio.charset.Charset; import java.text.MessageFormat; import java.util.ArrayList; import java.util.Collections; @@ -37,6 +39,7 @@ import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.model.ContentModel; import org.alfresco.repo.configuration.ConfigurableService; import org.alfresco.repo.content.MimetypeMap; +import org.alfresco.repo.content.encoding.ContentCharsetFinder; import org.alfresco.repo.content.metadata.MetadataExtracter; import org.alfresco.repo.content.metadata.MetadataExtracterRegistry; import org.alfresco.repo.transaction.RetryingTransactionHelper; @@ -507,6 +510,21 @@ public final class Repository return false; } } + + /** + * Extract the characterset from the stream + * + * @param context the Faces Context + * @param is the stream of characters or data + * @param mimetype the stream's mimetype, or null if unknown + * @return Returns the guessed characterset and never null + */ + public static String guessEncoding(FacesContext context, InputStream is, String mimetype) + { + ContentCharsetFinder charsetFinder = getServiceRegistry(context).getMimetypeService().getContentCharsetFinder(); + Charset charset = charsetFinder.getCharset(is, mimetype); + return charset.name(); + } /** * Query a list of Person type nodes from the repo diff --git a/source/java/org/alfresco/web/bean/wcm/AddAvmContentDialog.java b/source/java/org/alfresco/web/bean/wcm/AddAvmContentDialog.java index bccfd7814b..4830e794c4 100644 --- a/source/java/org/alfresco/web/bean/wcm/AddAvmContentDialog.java +++ b/source/java/org/alfresco/web/bean/wcm/AddAvmContentDialog.java @@ -37,7 +37,6 @@ import org.alfresco.service.cmr.avm.AVMService; import org.alfresco.service.cmr.repository.ContentWriter; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.namespace.QName; -import org.alfresco.web.app.AlfrescoNavigationHandler; import org.alfresco.web.bean.content.AddContentDialog; /** @@ -101,7 +100,7 @@ public class AddAvmContentDialog extends AddContentDialog // get a writer for the content and put the file ContentWriter writer = contentService.getWriter(fileNodeRef, ContentModel.PROP_CONTENT, true); writer.setMimetype(this.mimeType); - writer.setEncoding("UTF-8"); + writer.setEncoding(this.encoding); if (fileContent != null) { writer.putContent(fileContent); diff --git a/source/java/org/alfresco/web/ui/repo/component/UICharsetSelector.java b/source/java/org/alfresco/web/ui/repo/component/UICharsetSelector.java new file mode 100644 index 0000000000..cfb59be485 --- /dev/null +++ b/source/java/org/alfresco/web/ui/repo/component/UICharsetSelector.java @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2005-2007 Alfresco Software Limited. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + * As a special exception to the terms and conditions of version 2.0 of + * the GPL, you may redistribute this Program in connection with Free/Libre + * and Open Source Software ("FLOSS") applications as described in Alfresco's + * FLOSS exception. You should have recieved a copy of the text describing + * the FLOSS exception, and it is also available here: + * http://www.alfresco.com/legal/licensing" + */ +package org.alfresco.web.ui.repo.component; + +import java.io.IOException; +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import javax.faces.component.UISelectItems; +import javax.faces.component.UISelectOne; +import javax.faces.context.FacesContext; +import javax.faces.model.SelectItem; + +/** + * Component that holds a list of characterset encodings supported by the repository. + * + * @since 2.1 + * @author Derek Hulley + */ +public class UICharsetSelector extends UISelectOne +{ + public static final String COMPONENT_TYPE = "org.alfresco.faces.CharsetSelector"; + public static final String COMPONENT_FAMILY = "javax.faces.SelectOne"; + + @Override + @SuppressWarnings("unchecked") + public void encodeBegin(FacesContext context) throws IOException + { + // if the component does not have any children yet create the + // list of Charsets the user can choose from as a child + // SelectItems component. + if (getChildren().size() == 0) + { + UISelectItems items = (UISelectItems)context.getApplication().createComponent("javax.faces.SelectItems"); + items.setId(this.getId() + "_items"); + items.setValue(createList()); + + // add the child component + getChildren().add(items); + } + + // do the default processing + super.encodeBegin(context); + } + + /** + * Creates the list of SelectItem components to represent the list + * of Charsets the user can select from + * + * @return List of SelectItem components + */ + protected List createList() + { + Map availableCharsets = Charset.availableCharsets(); + List items = new ArrayList(availableCharsets.size()); + for (Charset charset : availableCharsets.values()) + { + SelectItem item = new SelectItem(charset.name(), charset.displayName()); + items.add(item); + } + return items; + } +} diff --git a/source/java/org/alfresco/web/ui/repo/converter/CharsetConverter.java b/source/java/org/alfresco/web/ui/repo/converter/CharsetConverter.java new file mode 100644 index 0000000000..a62676c5e6 --- /dev/null +++ b/source/java/org/alfresco/web/ui/repo/converter/CharsetConverter.java @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2005-2007 Alfresco Software Limited. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + * As a special exception to the terms and conditions of version 2.0 of + * the GPL, you may redistribute this Program in connection with Free/Libre + * and Open Source Software ("FLOSS") applications as described in Alfresco's + * FLOSS exception. You should have recieved a copy of the text describing + * the FLOSS exception, and it is also available here: + * http://www.alfresco.com/legal/licensing" + */ +package org.alfresco.web.ui.repo.converter; + +import java.nio.charset.Charset; + +import javax.faces.component.UIComponent; +import javax.faces.context.FacesContext; +import javax.faces.convert.Converter; + +import org.alfresco.i18n.I18NUtil; + +/** + * Converter class to convert a Charset to a String + * + * @since 2.1 + * @author Derek Hulley + */ +public class CharsetConverter implements Converter +{ + /** + *

The standard converter id for this converter.

+ */ + public static final String CONVERTER_ID = "org.alfresco.faces.CharsetConverter"; + + /** + * {@inheritDoc} + */ + public Object getAsObject(FacesContext context, UIComponent component, String value) + { + return value; + } + + /** + * {@inheritDoc} + */ + public String getAsString(FacesContext context, UIComponent component, Object value) + { + if (value == null) + { + throw new IllegalArgumentException(I18NUtil.getMessage("error_charset_null")); + } + + String result = null; + + if (value instanceof Charset) + { + result = ((Charset)value).name(); + } + else if (value != null) + { + result = value.toString(); + } + + return result; + } +} diff --git a/source/java/org/alfresco/web/ui/repo/converter/MimeTypeConverter.java b/source/java/org/alfresco/web/ui/repo/converter/MimeTypeConverter.java index 8f4c88393e..929259a6b3 100644 --- a/source/java/org/alfresco/web/ui/repo/converter/MimeTypeConverter.java +++ b/source/java/org/alfresco/web/ui/repo/converter/MimeTypeConverter.java @@ -32,7 +32,7 @@ import org.alfresco.service.cmr.repository.MimetypeService; import org.alfresco.web.bean.repository.Repository; /** - * Converter class to convert an XML date representation into a Date + * Converter class to convert a MIME type to an appropriate display name * * @author gavinc */ diff --git a/source/java/org/alfresco/web/ui/repo/tag/CharsetSelectorTag.java b/source/java/org/alfresco/web/ui/repo/tag/CharsetSelectorTag.java new file mode 100644 index 0000000000..1b873b7016 --- /dev/null +++ b/source/java/org/alfresco/web/ui/repo/tag/CharsetSelectorTag.java @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2005-2007 Alfresco Software Limited. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + * As a special exception to the terms and conditions of version 2.0 of + * the GPL, you may redistribute this Program in connection with Free/Libre + * and Open Source Software ("FLOSS") applications as described in Alfresco's + * FLOSS exception. You should have recieved a copy of the text describing + * the FLOSS exception, and it is also available here: + * http://www.alfresco.com/legal/licensing" + */ +package org.alfresco.web.ui.repo.tag; + +import javax.faces.component.UIComponent; + +import org.alfresco.web.ui.common.ComponentConstants; +import org.alfresco.web.ui.common.tag.HtmlComponentTag; +import org.alfresco.web.ui.repo.component.UICharsetSelector; + +/** + * Tag class for the Charset selector component + * + * @since 2.1 + * @author Derek Hulley + */ +public class CharsetSelectorTag extends HtmlComponentTag +{ + /** The value */ + private String value; + + /** Whether the component is disabled */ + private String disabled; + + @Override + public String getComponentType() + { + return UICharsetSelector.COMPONENT_TYPE; + } + + @Override + public String getRendererType() + { + return ComponentConstants.JAVAX_FACES_MENU; + } + + @Override + protected void setProperties(UIComponent component) + { + super.setProperties(component); + + setStringBindingProperty(component, "value", this.value); + setBooleanProperty(component, "disabled", this.disabled); + } + + @Override + public void release() + { + super.release(); + + this.value = null; + this.disabled = null; + } + + /** + * Set the value + * + * @param value the value + */ + public void setValue(String value) + { + this.value = value; + } + + /** + * Sets whether the component should be rendered in a disabled state + * + * @param disabled true to render the component in a disabled state + */ + public void setDisabled(String disabled) + { + this.disabled = disabled; + } +} diff --git a/source/web/WEB-INF/faces-config-repo.xml b/source/web/WEB-INF/faces-config-repo.xml index 9babcf1e8b..6532567c0a 100644 --- a/source/web/WEB-INF/faces-config-repo.xml +++ b/source/web/WEB-INF/faces-config-repo.xml @@ -79,6 +79,11 @@ org.alfresco.web.ui.repo.component.UILanguageSelector + + org.alfresco.faces.CharsetSelector + org.alfresco.web.ui.repo.component.UICharsetSelector + + org.alfresco.faces.SimpleSearch org.alfresco.web.ui.repo.component.UISimpleSearch diff --git a/source/web/WEB-INF/repo.tld b/source/web/WEB-INF/repo.tld index 5cb9c410ed..506f6062d0 100644 --- a/source/web/WEB-INF/repo.tld +++ b/source/web/WEB-INF/repo.tld @@ -1034,6 +1034,42 @@ + + charsetSelector + org.alfresco.web.ui.repo.tag.CharsetSelectorTag + JSP + + + id + false + true + + + + binding + false + true + + + + rendered + false + true + + + + value + false + true + + + + disabled + false + true + + + shelf org.alfresco.web.ui.repo.tag.shelf.ShelfTag diff --git a/source/web/jsp/content/add-content-dialog.jsp b/source/web/jsp/content/add-content-dialog.jsp index 2a89cc67f8..472bd34605 100644 --- a/source/web/jsp/content/add-content-dialog.jsp +++ b/source/web/jsp/content/add-content-dialog.jsp @@ -224,6 +224,17 @@ if (dialog != null && dialog.getFileName() != null) + + + + + + + + + + + diff --git a/source/web/jsp/wcm/add-content-dialog.jsp b/source/web/jsp/wcm/add-content-dialog.jsp index 4db2f2018e..08e8549011 100644 --- a/source/web/jsp/wcm/add-content-dialog.jsp +++ b/source/web/jsp/wcm/add-content-dialog.jsp @@ -222,6 +222,15 @@ if (dialog != null && dialog.getFileName() != null) + + + + + + + + + <% } %>