As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
<!– add supinfo types to add content list (add content page) –> <config evaluator="string-compare" condition="Content Wizards" replace="true"> <content-types> <type name="ls:essential" displaylabelid="essential" /> <type name="ls:annex" displaylabelid="annex"/> <type name="ls:exerciseBook" displaylabelid="exerciseBook"/> <type name="ls:slide" displaylabelid="slide"/> <type name="ls:exerciceCorr" displaylabelid="exerciceCorr"/> </content-types> </config>
this.objectTypes.add(new SelectItem(ContentModel.TYPE_CONTENT.toString(), Application.getMessage(context, "content")));
package org.alfresco.sample; import java.util.ArrayList; import java.util.List; import javax.faces.context.FacesContext; import javax.faces.model.SelectItem; import org.alfresco.config.Config; import org.alfresco.config.ConfigElement; import org.alfresco.config.ConfigService; import org.alfresco.model.ContentModel; import org.alfresco.service.cmr.dictionary.TypeDefinition; import org.alfresco.service.namespace.QName; import org.alfresco.web.app.Application; import org.alfresco.web.bean.content.AddContentDialog; import org.alfresco.web.bean.content.CreateContentWizard; import org.alfresco.web.bean.repository.Repository; import org.alfresco.web.data.IDataContainer; import org.alfresco.web.data.QuickSort; import org.alfresco.web.ui.common.Utils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; public class CustomAddContentDialog extends AddContentDialog { protected static Log logger = LogFactory.getLog(CreateContentWizard.class); /** * @return Returns a list of object types to allow the user to select from */ @Override public List<SelectItem> getObjectTypes() { if (this.objectTypes == null) { FacesContext context = FacesContext.getCurrentInstance(); // add the well known object type to start with this.objectTypes = new ArrayList<SelectItem>(5); // don't want the "content" choice // this.objectTypes.add(new // SelectItem(ContentModel.TYPE_CONTENT.toString(), // Application.getMessage(context, "content"))); // add any configured content sub-types to the list ConfigService svc = Application.getConfigService(FacesContext .getCurrentInstance()); Config wizardCfg = svc.getConfig("Content Wizards"); if (wizardCfg != null) { ConfigElement typesCfg = wizardCfg .getConfigElement("content-types"); if (typesCfg != null) { for (ConfigElement child : typesCfg.getChildren()) { QName idQName = Repository.resolveToQName(child .getAttribute("name")); if (idQName != null) { TypeDefinition typeDef = this.dictionaryService .getType(idQName); if (typeDef != null) { if (this.dictionaryService.isSubClass(typeDef .getName(), ContentModel.TYPE_CONTENT)) { // try and get the display label from config String label = Utils.getDisplayLabel( context, child); // if there wasn't a client based label try // and get it from the dictionary if (label == null) { label = typeDef.getTitle(); } // finally, just use the localname if (label == null) { label = idQName.getLocalName(); } this.objectTypes.add(new SelectItem(idQName .toString(), label)); } else { logger .warn("Failed to add '" + child .getAttribute("name") + "' to the list of content types as the type is not a subtype of cm:content"); } } else { logger .warn("Failed to add '" + child.getAttribute("name") + "' to the list of content types as the type is not recognised"); } } } // make sure the list is sorted by the label QuickSort sorter = new QuickSort(this.objectTypes, "label", true, IDataContainer.SORT_CASEINSENSITIVE); sorter.sort(); } else { logger .warn("Could not find 'content-types' configuration element"); } } else { logger .warn("Could not find 'Content Wizards' configuration section"); } } return this.objectTypes; } }
<managed-bean> <description> The bean that backs up the Add Content Dialog </description> <managed-bean-name>AddContentDialog</managed-bean-name> <managed-bean-class>org.alfresco.sample.CustomAddContentDialog</managed-bean-class> <managed-bean-scope>session</managed-bean-scope> <managed-property> <property-name>nodeService</property-name> <value>#{NodeService}</value> </managed-property> <managed-property> <property-name>fileFolderService</property-name> <value>#{FileFolderService}</value> </managed-property> <managed-property> <property-name>searchService</property-name> <value>#{SearchService}</value> </managed-property> <managed-property> <property-name>navigator</property-name> <value>#{NavigationBean}</value> </managed-property> <managed-property> <property-name>browseBean</property-name> <value>#{BrowseBean}</value> </managed-property> <managed-property> <property-name>contentService</property-name> <value>#{ContentService}</value> </managed-property> <managed-property> <property-name>dictionaryService</property-name> <value>#{DictionaryService}</value> </managed-property> </managed-bean>
THANK YOU VERY MUCH.First I did what you said, and it worked well with the CreateContentWizardBut it didn't for the AddContentDialog.(I mean I didn't know how to declare the managed bean I wanted to use in the web-client-config-custom.) So I did like that, I don't thing that is the best method because I didn't add my CustomAddContentDialog but I change the bean AddContentDialog for my CustomAddContentDialog.this is my CustomAddContentDialog : package org.alfresco.sample; import java.util.ArrayList; import java.util.List; import javax.faces.context.FacesContext; import javax.faces.model.SelectItem; import org.alfresco.config.Config; import org.alfresco.config.ConfigElement; import org.alfresco.config.ConfigService; import org.alfresco.model.ContentModel; import org.alfresco.service.cmr.dictionary.TypeDefinition; import org.alfresco.service.namespace.QName; import org.alfresco.web.app.Application; import org.alfresco.web.bean.content.AddContentDialog; import org.alfresco.web.bean.content.CreateContentWizard; import org.alfresco.web.bean.repository.Repository; import org.alfresco.web.data.IDataContainer; import org.alfresco.web.data.QuickSort; import org.alfresco.web.ui.common.Utils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; public class CustomAddContentDialog extends AddContentDialog { protected static Log logger = LogFactory.getLog(CreateContentWizard.class); /** * @return Returns a list of object types to allow the user to select from */ @Override public List<SelectItem> getObjectTypes() { if (this.objectTypes == null) { FacesContext context = FacesContext.getCurrentInstance(); // add the well known object type to start with this.objectTypes = new ArrayList<SelectItem>(5); // don't want the "content" choice // this.objectTypes.add(new // SelectItem(ContentModel.TYPE_CONTENT.toString(), // Application.getMessage(context, "content"))); // add any configured content sub-types to the list ConfigService svc = Application.getConfigService(FacesContext .getCurrentInstance()); Config wizardCfg = svc.getConfig("Content Wizards"); if (wizardCfg != null) { ConfigElement typesCfg = wizardCfg .getConfigElement("content-types"); if (typesCfg != null) { for (ConfigElement child : typesCfg.getChildren()) { QName idQName = Repository.resolveToQName(child .getAttribute("name")); if (idQName != null) { TypeDefinition typeDef = this.dictionaryService .getType(idQName); if (typeDef != null) { if (this.dictionaryService.isSubClass(typeDef .getName(), ContentModel.TYPE_CONTENT)) { // try and get the display label from config String label = Utils.getDisplayLabel( context, child); // if there wasn't a client based label try // and get it from the dictionary if (label == null) { label = typeDef.getTitle(); } // finally, just use the localname if (label == null) { label = idQName.getLocalName(); } this.objectTypes.add(new SelectItem(idQName .toString(), label)); } else { logger .warn("Failed to add '" + child .getAttribute("name") + "' to the list of content types as the type is not a subtype of cm:content"); } } else { logger .warn("Failed to add '" + child.getAttribute("name") + "' to the list of content types as the type is not recognised"); } } } // make sure the list is sorted by the label QuickSort sorter = new QuickSort(this.objectTypes, "label", true, IDataContainer.SORT_CASEINSENSITIVE); sorter.sort(); } else { logger .warn("Could not find 'content-types' configuration element"); } } else { logger .warn("Could not find 'Content Wizards' configuration section"); } } return this.objectTypes; } } and my faces-config-custom.xml <managed-bean> <description> The bean that backs up the Add Content Dialog </description> <managed-bean-name>AddContentDialog</managed-bean-name> <managed-bean-class>org.alfresco.sample.CustomAddContentDialog</managed-bean-class> <managed-bean-scope>session</managed-bean-scope> <managed-property> <property-name>nodeService</property-name> <value>#{NodeService}</value> </managed-property> <managed-property> <property-name>fileFolderService</property-name> <value>#{FileFolderService}</value> </managed-property> <managed-property> <property-name>searchService</property-name> <value>#{SearchService}</value> </managed-property> <managed-property> <property-name>navigator</property-name> <value>#{NavigationBean}</value> </managed-property> <managed-property> <property-name>browseBean</property-name> <value>#{BrowseBean}</value> </managed-property> <managed-property> <property-name>contentService</property-name> <value>#{ContentService}</value> </managed-property> <managed-property> <property-name>dictionaryService</property-name> <value>#{DictionaryService}</value> </managed-property> </managed-bean> Do you know how I can change the managed bean for the AddContentDialog in my web-client-config-custom ?