cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Data List

pmbhalerao
Champ in-the-making
Champ in-the-making
Hello team,

I am very new to Alfresco. I have installed Alfresco Community v3.4.0 on Windows platform and and it's working well.

I need to create some custom lists. I saw some posts, but I am not 100% clear. Are there any step by step instructions on how to go about it? I saw mention of Eclipse on YouTube, but not sure where to find it and which Eclipse tool I need to use.

Any help?

Thanks

Parag Bhalerao
25 REPLIES 25

efvrvo
Champ on-the-rise
Champ on-the-rise
I'll give an example:
I created a list "General correspondence"

First I create a file "gcDatalistModel.xml" in the folder "C:\Alfresco\tomcat\shared\classes\alfresco\extension\"
This is the file that will hold my model (data list) definition

The file has the following content:

<?xml version="1.0" encoding="UTF-8"?>

<!– Definition of new Model –>

<model name="gc:gcDatalist" xmlns="http://www.alfresco.org/model/dictionary/1.0">

   <!– Optional meta-data about the model –>  
   <description>Custom Bhukka datalist</description>
   <author>Eugene vRvOudtshoorn</author>
   <version>1.0</version>

   <!– Imports are required to allow references to definitions in other models –>  
   <imports>
        <!– Import Alfresco Dictionary Definitions –>
      <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
      <!– Import Alfresco Content Domain Model Definitions –>
      <import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
     <!– Import Alfresco Data List Model Definitions –>
      <import uri="http://www.alfresco.org/model/datalist/1.0" prefix="dl"/>
   </imports>

   <!– Introduction of new namespaces defined by this model –>  
   <namespaces>
       <namespace uri="gc.customlists.com" prefix="gc"/>
   </namespaces>
  
 
   <!–      T Y P E   D E F I N I T I O N S      –>  
   <types>
     <!–   Data list defintions For this model go here –>
      <type name="gc:generalCor">
       <title>General correspondence</title>
       <description>General correspondence</description>
       <parent>dl:dataListItem</parent>
       <properties>
         <property name="gc:gcID">
            <title>GC number</title>
            <type>d:text</type>
            <mandatory>true</mandatory>
         </property>
         <property name="gc:gcIDclient">
            <title>Client ref number</title>
            <type>d:text</type>
            <mandatory>false</mandatory>
         </property>
         <property name="gc:gcTitle">
            <title>Title</title>
            <type>d:text</type>
            <mandatory>true</mandatory>
         </property>
         <property name="gc:gcComments">
            <title>Comments</title>
            <type>d:text</type>
            <mandatory>false</mandatory>
         </property>
         <property name="gc:gcRefCor">
            <title>Ref correspondence</title>
            <type>d:text</type>
            <mandatory>false</mandatory>
         </property>
      </properties>      

       <associations>
         <association name="gc:gcAttachments">
            <title>Attachements</title>
            <source>
              <mandatory>false</mandatory>
              <many>true</many>
            </source>
            <target>
              <class>cm:content</class>
              <mandatory>false</mandatory>
              <many>true</many>
            </target>
         </association>
       </associations>
     </type>
   </types>    
</model>



The way it works is as follows:

<model name="gc:gcDatalist" xmlns="http://www.alfresco.org/model/dictionary/1.0">

You give your new model a name in the bold section. It can be anything as long as it has a prefix "gc" followed by ":" and then a name "gcDatalist"

The import section attaches other models so that your model can be build as a child using definitions already set in these models
<imports>
        <!– Import Alfresco Dictionary Definitions –>
      <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
      <!– Import Alfresco Content Domain Model Definitions –>
      <import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
     <!– Import Alfresco Data List Model Definitions –>
      <import uri="http://www.alfresco.org/model/datalist/1.0" prefix="dl"/>
   </imports>

The name space section is used to set a uri and prefix for the model. The uri can be anything
<namespace uri="gc.customlists.com" prefix="gc"/>

Now we define a model type with properties and associations (data list name with columns)

 <types>
     <!–   Data list defintions For this model go here –>
      <type name="gc:generalCor">
       <title>General correspondence</title>
       <description>General correspondence</description>
       <parent>dl:dataListItem</parent>
       <properties>
         <property name="gc:gcID">
            <title>GC number</title>
            <type>d:text</type>
            <mandatory>true</mandatory>
         </property>
         <property name="gc:gcIDclient">
            <title>Client ref number</title>
            <type>d:text</type>
            <mandatory>false</mandatory>
         </property>
         <property name="gc:gcTitle">
            <title>Title</title>
            <type>d:text</type>
            <mandatory>true</mandatory>
         </property>
         <property name="gc:gcComments">
            <title>Comments</title>
            <type>d:text</type>
            <mandatory>false</mandatory>
         </property>
         <property name="gc:gcRefCor">
            <title>Ref correspondence</title>
            <type>d:text</type>
            <mandatory>false</mandatory>
         </property>
      </properties>      

       <associations>
         <association name="gc:gcAttachments">
            <title>Attachements</title>
            <source>
              <mandatory>false</mandatory>
              <many>true</many>
            </source>
            <target>
              <class>cm:content</class>
              <mandatory>false</mandatory>
              <many>true</many>
            </target>
         </association>
       </associations>
     </type>
   </types>    

As i stated the properties and associations are your columns in the datalist. I think this section is easy to understand. The associations allow you to attach files the the list.

The model is now defined and we now have to tell share what to display when
Open the file "share-config-custom.xml" located in "C:\Alfresco\tomcat\shared\classes\alfresco\web-extension\"
Scroll to the bottom of the file and insert the following code (insert before the close of the file </alfresco-config>)

<!– General correspondence –>

   <config evaluator="model-type" condition="gc:generalCor">
      <forms>
         <!– Create item form –>
         <form>
            <field-visibility>
               <!– for the form creation we are showing everything except approved date –>
                     <show id="gc:gcID" />            
               <show id="gc:gcIDclient" />                              
               <show id="gc:gcTitle" />               
               <show id="gc:gcComments" />                     
               <show id="gc:gcAttachments" />
            </field-visibility>
            <create-form template="/org/alfresco/components/data-lists/forms/dataitem.ftl" />
            <appearance>
               <field id="gc:gcIDclient">
                  <control template="/org/alfresco/components/form/controls/textarea.ftl" />
               </field>
               
               <field id="gc:gcComments">
                  <control template="/org/alfresco/components/form/controls/textarea.ftl" />
               </field>                   
               <field id="gc:gcAttachments">
                  <control>
                   <control-param name="startLocation">{doclib}</control-param>
                  </control>
                   </field>
            </appearance>
         </form>

               <!– Data Grid view –>
               <form id="datagrid">
                     <field-visibility>                     
               <show id="gc:gcID" />            
               <show id="gc:gcIDclient" />                              
               <show id="gc:gcTitle" />               
               <show id="gc:gcComments" />                     
               <show id="gc:gcAttachments" />    
                     </field-visibility>
               </form>
         </forms>
      </config>
   
   <!– Edit view –>
   <config evaluator="node-type" condition="gc:generalCor">
      <forms>
         <!– Edit marketing item form –>
         <form>
            <field-visibility>
                        <show id="gc:gcID" />            
               <show id="gc:gcIDclient" />                              
               <show id="gc:gcTitle" />               
               <show id="gc:gcComments" />                     
               <show id="gc:gcAttachments" />
            </field-visibility>
            <create-form template="/org/alfresco/components/data-lists/forms/dataitem.ftl" />
            <appearance>
               <field id="gc:gcIDclient">
                  <control template="/org/alfresco/components/form/controls/textarea.ftl" />
               </field>
               
               <field id="gc:gcComments">
                  <control template="/org/alfresco/components/form/controls/textarea.ftl" />
               </field>                   
               <field id="gc:gcAttachments">
                  <control>
                   <control-param name="startLocation">{doclib}</control-param>
                  </control>
                   </field>
            </appearance>
      
         </form>
      </forms>
   </config>

The code works as follows:
The section "<config evaluator="model-type" condition="gc:generalCor">" is were you tell share the datalist under discussion. This is not your model name but your type name

<!– Create item form –>
         <form>
            <field-visibility>
               <!– for the form creation we are showing everything except approved date –>
                     <show id="gc:gcID" />            
               <show id="gc:gcIDclient" />                              
               <show id="gc:gcTitle" />               
               <show id="gc:gcComments" />                     
               <show id="gc:gcAttachments" />
            </field-visibility>
            <create-form template="/org/alfresco/components/data-lists/forms/dataitem.ftl" />
            <appearance>
               <field id="gc:gcIDclient">
                  <control template="/org/alfresco/components/form/controls/textarea.ftl" />
               </field>
               
               <field id="gc:gcComments">
                  <control template="/org/alfresco/components/form/controls/textarea.ftl" />
               </field>                   
               <field id="gc:gcAttachments">
                  <control>
                   <control-param name="startLocation">{doclib}</control-param>
                  </control>
                   </field>
            </appearance>
         </form>

This section is were you indicate which properties and associations are to be displayed when you create the datalist

<!– Data Grid view –>
               <form id="datagrid">
                     <field-visibility>                     
               <show id="gc:gcID" />            
               <show id="gc:gcIDclient" />                              
               <show id="gc:gcTitle" />               
               <show id="gc:gcComments" />                     
               <show id="gc:gcAttachments" />    
                     </field-visibility>
               </form>

Here you define the columns to display

<!– Edit view –>
   <config evaluator="node-type" condition="gc:generalCor">
      <forms>
         <!– Edit marketing item form –>
         <form>
            <field-visibility>
                        <show id="gc:gcID" />            
               <show id="gc:gcIDclient" />                              
               <show id="gc:gcTitle" />               
               <show id="gc:gcComments" />                     
               <show id="gc:gcAttachments" />
            </field-visibility>
            <create-form template="/org/alfresco/components/data-lists/forms/dataitem.ftl" />
            <appearance>
               <field id="gc:gcIDclient">
                  <control template="/org/alfresco/components/form/controls/textarea.ftl" />
               </field>
               
               <field id="gc:gcComments">
                  <control template="/org/alfresco/components/form/controls/textarea.ftl" />
               </field>                   
               <field id="gc:gcAttachments">
                  <control>
                   <control-param name="startLocation">{doclib}</control-param>
                  </control>
                   </field>
            </appearance>
      
         </form>
      </forms>
   </config>

Here you define the items to display when you edit the data list

Now share knows what to display when. Next you have to create a file named "CustomDatalist-model-context.xml" the name is not important as long as you end the file with "-context.xml"
Store the file in "C:\Alfresco\tomcat\shared\classes\alfresco\extension\"
Add in the file the following

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>

<beans>

    <!– Registration of new models –> 
<bean id="extension.gc.dictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap">
        <property name="models">
            <list>
                <value>alfresco/extension/gcDatalistModel.xml</value>
            </list>
        </property>
    </bean>

<bean id="extension.mtg.dictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap">
        <property name="models">
            <list>
                <value>alfresco/extension/mtgDatalistModel.xml</value>
            </list>
        </property>
    </bean>

</beans>

I included a second model to demonstrate how you can load other models later on. but for this demo the important section is
<bean id="extension.gc.dictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap">
        <property name="models">
            <list>
                <value>alfresco/extension/gcDatalistModel.xml</value>
            </list>
        </property>
    </bean>

With all the files in place you can now restart the server and it will load your new data lists

sathesh
Champ in-the-making
Champ in-the-making

can u help me pls...

while clicking attachments select button in adding new item in custom data list, I want to add files from windows explorer in client side instead of from server.

abve image is adding attachments from server i dont want that, i want to add files from windows explorer in client pc.

renahan
Champ in-the-making
Champ in-the-making
I've followed your tutorial and I received many errors reported on the admin dashboard, printed on the webpage. Error 500, 400 and various other tings. Everything improved only after I deleted both of the xml files from the extensions folder. Any ideas? If I'm not mistaken, all that must be done is add the two xmls to the extensions folder and add that snippet of code to the shared.config.custom.xml, right?

By the way, do you know how to arrange the columns in a desired order? When I was able to dynamically add the gcDatalistModel.xml directly into Alfresco via repository/data dictionary/models and making the content active, everything worked fine. So I made my own data list model but when I went to use it, the columns were all over the place. No rhyme or reason to it. After uploading edited xmls, the data lists seemed to become unstable as I could not do anything; couldn't delete the xmls, deactivate them, they would only randomly show up as an option for a new list after refreshing the page several times. When attempting to upload I got some wild errors in catalina.out file. So I haven't been able to figure anything out. I've re-installed Alfresco several times. It works with the very first upload of the xml but starts to throw out errors very soon after that.

efvrvo
Champ on-the-rise
Champ on-the-rise
send me your email address then I will email the files to you to have a look at and test. If they work then all you need to do is change the data to what you require

mizage
Champ in-the-making
Champ in-the-making
this worked like a charm. Thanks.

alex_chew
Champ in-the-making
Champ in-the-making
Could you please send me the files? I am also trying to customize data list to archive business requirement. My email address is alex_chew(AT)msn.com. Many thanks.

efvrvo
Champ on-the-rise
Champ on-the-rise
What i suggest is to try first the customisation as I explained it earlier in this thread. The reason I asked for his files is so that I can see what was wrong. After you try what I outlined above post your problems here and I will have a look at them. Or ask your questions here and I will try and answer them

amunot
Champ in-the-making
Champ in-the-making
I tried the steps above and noticed the following errors on the Std. Out: 
2012-04-25 11:39:19,431  ERROR [web.context.ContextLoader] [Thread-1] Context initialization failed
org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'extension.gc.dictionaryBootstrap' defined in file [C:\Alfresco\tomcat\shared\classes\alfresco\web-extension\CustomDatalist-model-context.xml]: Could not resolve parent bean definition 'dictionaryModelBootstrap'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'dictionaryModelBootstrap' is defined.

Any Ideas as to whats wrong?

clearf
Champ in-the-making
Champ in-the-making
I'm certainly no expert, but I'll take a guess that it thinks you're trying to extend "share," not the alfresco repository. Put the file in "C:\Alfresco\tomcat\shared\classes\alfresco\extension\" instead of "C:\Alfresco\tomcat\shared\classes\alfresco\web-extension\."

Chris