cancel
Showing results for 
Search instead for 
Did you mean: 

Remove the content type 'content' in the Add conte

fif
Champ in-the-making
Champ in-the-making
Hello

I tried to add new types in my model.
So I changed my model (that was ok)
Then I changed the web-client-config-custom to add these new types in the "add content wizard" in the web client.



   <!–  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>

It's works but, now when I want to add a new content. i still have the "content" choice in addition of the types described (essential,annex,exerciseBook,…)
And I added the replace="true" attribute  ! ! !

How can I remove it from the web client ?
if you have any idea …  Smiley Very Happy
Thanks in advance
8 REPLIES 8

gavinc
Champ in-the-making
Champ in-the-making
The default 'Content' type gets added in code which is why you can't get rid of it, you tried exactly the right thing though!

If you look at org.alfresco.web.bean.content.BaseContentWizard and the getObjectTypes() method you'll see the following line:


this.objectTypes.add(new SelectItem(ContentModel.TYPE_CONTENT.toString(),
               Application.getMessage(context, "content")));

You can either comment this out or override the wizard definition in config by specifying a custom bean that extends CreateContentWizard (see http://wiki.alfresco.com/wiki/Customising_The_Create_Content_Wizard for an example of how to do this) which overrides the getObjectTypes() method and doesn't add the default type.

fif
Champ in-the-making
Champ in-the-making
THANK YOU VERY MUCH.

First I did what you said, and it worked well with the CreateContentWizard

But 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 ?

gavinc
Champ in-the-making
Champ in-the-making
Unfortunatley the add-content-dialog.jsp is not a true 'dialog' in that the page is a full JSP, so it doesn't benefit from the bean name abstraction all other dialogs and wizards use.

What you have done so far is correct, I'm guessing that your custom behaviour is not showing up? This is because you'll have to change the bean references in add-content-dialog.jsp as well. Replace all occurrences of 'AddContentDialog' with 'CustomAddContentDialog' and it should work. The downside obviously is that you have to change a core Alfresco file.

Please feel free to raise an issue in JIRA to make the list of types configurable i.e. so you can remove the default 'Content' type.

fif
Champ in-the-making
Champ in-the-making
Ok, I post on JIRA :
http://issues.alfresco.com/browse/AWC-1575

I don't understand really what you mean by "I'm guessing that your custom behaviour is not showing up". Everything is working fine (until now) except that I think it was not a good way to do that.

Thank you very much.

gavinc
Champ in-the-making
Champ in-the-making
Ahh sorry, I didn't read your code/config close enough I can see that it should work. I presumed you were still having issues!

You're right it's not an ideal solution it should be a lot easier hence the reason I suggested you raise the issue in JIRA, thanks for that too.

alarocca
Champ in-the-making
Champ in-the-making
Well, this is interesting. I'm using custom models too and don't want to see the 'content' option. Those changes do the work.

Now, what happens when I put a document throug CIFS? What document type is assigned to it? Is the first option within the list? I created a 'Generic Document' model that any custom model extends. Is there any way to set this as default option (automatically applied by CIFS and selected on the web dialog)? Should I name it 'A Generic Document' to send it up on the list?

Best regards,
Alessandro

gavinc
Champ in-the-making
Champ in-the-making
CIFS is a separate interface than the web client so will not use any of the web client config files.

For CIFS you can setup a rule for the space (which you would do via the web client) to 'specialise' the type i.e. when something gets dropped in you change it's type to what you specify i.e. your "Generalised Document" type.

dfernandezgonza
Champ in-the-making
Champ in-the-making
THANK YOU VERY MUCH.

First I did what you said, and it worked well with the CreateContentWizard

But 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 ?


Here's an example, but's in spanish

http://forums.alfresco.com/es/viewtopic.php?f=18&t=3502&start=0