cancel
Showing results for 
Search instead for 
Did you mean: 

how to register a renderer for document library?

byc01
Champ in-the-making
Champ in-the-making
I want to add an additional line to the Document Library that displays the content (node) type.  In the share-config-custom.xml file, I have the following (note the line index="40"):

<config evaluator="string-compare" condition="DocumentLibrary" replace="true">
   <metadata-templates>
      <template id="default">
         <line index="10" id="date">{date}{size}</line>
         <line index="20" id="description" view="detailed">{description}</line>
         <line index="30" id="tags" view="detailed">{tags}</line>
         <line index="40" id="nodeType">Test here {nodeType}</line>
      </template>
   </metadata-templates>
</config>

<config evaluator="string-compare" condition="DocLibCustom">
   <dependencies>
      <js src="/alfresco/components/documentlibrary/nodeType_renderer.js"/>
   </dependencies>
</config>

Using the example from the 4.0 documentation (http://docs.alfresco.com/4.0/index.jsp?topic=%2Fcom.alfresco.enterprise.doc%2Fconcepts%2Fdoclib-clie...), I created the aforementioned nodeType_renderer.js file in the tomcat\shared\classes\alfresco\site-webscripts\org\alfresco\components\documentlibrary directory with the following code:

(function()
{
   var $html = Alfresco.util.encodeHTML,
      $isValueSet = Alfresco.util.isValueSet;

   if (Alfresco.DocumentList)
   {
      YAHOO.Bubbling.fire("registerRenderer",
      {
         propertyName: "nodeType",
         renderer: function nodeType_renderer(record, label)
         {
            var jsNode = record.jsNode,
               properties = jsNode.properties,
               id = Alfresco.util.generateDomId(),
               html = "";

            return '<span id="' + id + '" class="item">blue: ' + label + jsNode.type + '</span>';
         }
      });
   }
})();

When I view the Document Library, I only see the words "Test here".  As far as I can tell, there are no errors, so I'm guessing the renderer has not register itself.  The documentation does not go into much detail on this.  Where should I place the nodeType_renderer.js file and how do I get it to register?

Thanks.
1 REPLY 1

byc01
Champ in-the-making
Champ in-the-making
Found the solution to this.  In the share-config-custom.xml file, I changed the DocLibCustom to the following

<dependencies>
   <js src="/components/custom/renderer/nodeType.js"/>
</dependencies>

I put the nodeType.js file into a jar with the following path:

META-INF/components/custom/renderer

Finally, I put the jar file in the tomcat/shared/lib directory.