diff --git a/config/alfresco/extension/web-client-config-custom.xml.sample b/config/alfresco/extension/web-client-config-custom.xml.sample index d7ac00b077..c31665617d 100644 --- a/config/alfresco/extension/web-client-config-custom.xml.sample +++ b/config/alfresco/extension/web-client-config-custom.xml.sample @@ -106,7 +106,7 @@ - + diff --git a/config/alfresco/messages/webclient_de.properties b/config/alfresco/messages/webclient_de.properties index 1c91c20d78..8b912e80fd 100644 --- a/config/alfresco/messages/webclient_de.properties +++ b/config/alfresco/messages/webclient_de.properties @@ -874,19 +874,19 @@ regenerate_renditions_desc=Anhand dieses Assistenten k\u00f6nnen Sie Renditions regenerate_renditions_select_renditions_title=Renditions ausw\u00e4hlen regenerate_renditions_select_renditions_step_title=Renditions ausw\u00e4hlen regenerate_renditions_select_renditions_desc=Die Renditions ausw\u00e4hlen, die erneuert werden sollen. -regenerate_renditions_select_renditions_select_item_desc={0} \u00e4hnliche {0,choice,0#renditions|1#rendition|1. + */ +package org.alfresco.web.bean.generator; + +import javax.faces.component.UIComponent; +import javax.faces.context.FacesContext; + +import org.alfresco.web.app.servlet.FacesHelper; +import org.alfresco.web.ui.repo.component.UIStoreSelector; + +/** + * Generates a content store selector component. + */ +public class StoreSelectorGenerator extends BaseComponentGenerator +{ + public UIComponent generate(FacesContext context, String id) + { + UIComponent component = context.getApplication(). + createComponent(UIStoreSelector.COMPONENT_TYPE); + FacesHelper.setupComponentId(context, component, id); + + return component; + } + +} diff --git a/source/java/org/alfresco/web/ui/repo/component/UIActions.java b/source/java/org/alfresco/web/ui/repo/component/UIActions.java index e046b0c188..0dfd366e71 100644 --- a/source/java/org/alfresco/web/ui/repo/component/UIActions.java +++ b/source/java/org/alfresco/web/ui/repo/component/UIActions.java @@ -19,6 +19,9 @@ package org.alfresco.web.ui.repo.component; import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.math.BigInteger; +import java.nio.charset.Charset; import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -35,6 +38,7 @@ import javax.faces.el.ValueBinding; import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.util.GUID; import org.alfresco.web.app.Application; import org.alfresco.web.bean.repository.Node; import org.alfresco.web.config.ActionsConfigElement; @@ -646,7 +650,20 @@ public class UIActions extends SelfRenderingComponent */ private static String createUniqueId() { - return "id_" + Short.toString(++id); + String guidString = GUID.generate(); + byte[] guidBytes = null; + try + { + guidBytes = guidString.getBytes("ISO8859_1"); + } + catch (UnsupportedEncodingException e) + { + //probably unreachable block, so just in case + Charset defaultCharset = Charset.defaultCharset(); + logger.warn("Can't get GUID bytes for encoding ISO8859_1, use default " + defaultCharset); + guidBytes = guidString.getBytes(defaultCharset); + } + return "id_" + new BigInteger(guidBytes).toString(Character.MAX_RADIX); } // ------------------------------------------------------------------------------ diff --git a/source/java/org/alfresco/web/ui/repo/component/UIStoreSelector.java b/source/java/org/alfresco/web/ui/repo/component/UIStoreSelector.java new file mode 100644 index 0000000000..a343af4faf --- /dev/null +++ b/source/java/org/alfresco/web/ui/repo/component/UIStoreSelector.java @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2005-2011 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.web.ui.repo.component; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import javax.faces.component.UISelectItems; +import javax.faces.component.UISelectOne; +import javax.faces.context.FacesContext; +import javax.faces.model.SelectItem; + +import org.alfresco.repo.dictionary.constraint.ConstraintRegistry; +import org.alfresco.repo.dictionary.constraint.ListOfValuesConstraint; +import org.alfresco.service.cmr.dictionary.Constraint; +import org.alfresco.web.data.IDataContainer; +import org.alfresco.web.data.QuickSort; + +/** + * Component that holds a list of content stores configured in the repository. + */ +public class UIStoreSelector extends UISelectOne +{ + public static final String COMPONENT_TYPE = "org.alfresco.faces.StoreSelector"; + public static final String COMPONENT_FAMILY = "javax.faces.SelectOne"; + + @Override + @SuppressWarnings("unchecked") + public void encodeBegin(FacesContext context) throws IOException + { + 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); + } + + /** + * @return List of SelectItem components + */ + protected List createList() + { + List items = new ArrayList(5); + Constraint storesConstraint = ConstraintRegistry.getInstance().getConstraint("defaultStoreSelector"); + for(String store : ((ListOfValuesConstraint) storesConstraint).getAllowedValues()) + { + items.add(new SelectItem(store, store)); + } + + // make sure the list is sorted by the values + QuickSort sorter = new QuickSort(items, "label", true, IDataContainer.SORT_CASEINSENSITIVE); + sorter.sort(); + + return items; + } +} diff --git a/source/web/WEB-INF/faces-config-beans.xml b/source/web/WEB-INF/faces-config-beans.xml index 871d4bc44c..0817f56f46 100644 --- a/source/web/WEB-INF/faces-config-beans.xml +++ b/source/web/WEB-INF/faces-config-beans.xml @@ -4618,6 +4618,15 @@ request + + + Bean that generates a stores selector component + + StoreSelectorGenerator + org.alfresco.web.bean.generator.StoreSelectorGenerator + request + + Bean that generates a charset selector component diff --git a/source/web/WEB-INF/faces-config-repo.xml b/source/web/WEB-INF/faces-config-repo.xml index 06172a7e43..275b57c1fd 100644 --- a/source/web/WEB-INF/faces-config-repo.xml +++ b/source/web/WEB-INF/faces-config-repo.xml @@ -74,6 +74,11 @@ org.alfresco.web.ui.repo.component.UIMimeTypeSelector + + org.alfresco.faces.StoreSelector + org.alfresco.web.ui.repo.component.UIStoreSelector + + org.alfresco.faces.LanguageSelector org.alfresco.web.ui.repo.component.UILanguageSelector