05-16-2012 06:01 AM
05-19-2012 04:55 AM
05-20-2012 08:45 AM
<#include "comments-list.get.head.ftl">
<!– Comments List –>
<link rel="stylesheet" type="text/css" href="http://172.18.101.35:8080/share/res/components/comments/comments-list.css" />
<script type="text/javascript" src="http://172.18.101.35:8080/share/res/components/comments/comments-list.js"></script>
<#if nodeRef??>
   <#assign el=args.htmlid?js_string>
   <script type="text/javascript">//<![CDATA[
      new Alfresco.CommentsList("${el}").setOptions(
      {
         nodeRef: "${nodeRef?js_string}",
         siteId: <#if site??>"${site?js_string}"<#else>null</#if>,
         maxItems: ${maxItems?js_string},
         activity: <#if activityParameterJSON??>${activityParameterJSON}<#else>null</#if>,
         editorConfig:
         {
            inline_styles: false,
            convert_fonts_to_spans: false,
            theme: "advanced",
            theme_advanced_buttons1: "bold,italic,underline,|,bullist,numlist,|,forecolor,|,undo,redo,removeformat",
            theme_advanced_toolbar_location: "top",
            theme_advanced_toolbar_align: "left",
            theme_advanced_resizing: true,
            theme_advanced_buttons2: null,
            theme_advanced_buttons3: null,
            theme_advanced_path: false,
            language: "${locale?substring(0, 2)?js_string}"
         }
      }).setMessages(
         ${messages}
      );
   //]]></script>
   <div id="${el}-body" class="comments-list">
      <h2 class="thin dark">${msg("header.comments")}</h2>
      <div id="${el}-add-comment">
         <div id="${el}-add-form-container" class="theme-bg-color-4 hidden"></div>
      </div>
      <div class="comments-list-actions">
         <div class="left">
            <div id="${el}-actions" class="hidden">
               <button class="alfresco-button" name=".onAddCommentClick">${msg("button.addComment")}</button>
            </div>
         </div>
         <div class="right">
            <div id="${el}-paginator-top"></div>
         </div>
         <div class="clear"></div>
      </div>
      <hr class="hidden"/>
      <div id="${el}-comments-list"></div>
      <hr class="hidden"/>
      <div class="comments-list-actions">
         <div class="left">
         </div>
         <div class="right">
            <div id="${el}-paginator-bottom"></div>
         </div>
         <div class="clear"></div>
      </div>
   </div>
</#if>05-20-2012 11:21 AM
05-20-2012 11:31 AM
05-23-2012 10:02 AM
remote.connect("alfresco").get('/api/metadata?nodeRef=' + nodeRef);
var this_AlfrescoUtil = this;
var AlfrescoUtil =
{
   error: function error(code, message, redirect)
   {
      status.code = arguments.length > 0 ? 500 : code;
      status.message = message || 'An error occured';
      status.redirect = arguments.length > 2 ? redirect : true;
      throw new Error(message);
   },
   /**
    * Looks for a parameter in a "safe" way that works in all "environments".
    * Meaning it will look in "page" and "template" if they do exist and not fail /crash if they don't.
    *
    * Looks for an argument in the following order/locations:
    * 1. args[name]
    * 2. page.url.args[name]        
    * 3. page.url.templateArgs[name]
    * 4. template.properties[name]
    * 5. a) if defaultValue has been passed in that is used
    *    b) otherwise the parameter is treated as required and an error is thrown
    *
    * @param name
    * @param defaultValue
    * @return the value for the parameter
    */
   param: function param(name, defaultValue)
   {
      var value;
      if (args[name] && args[name].length != 0)
      {
         value = args[name];
      }
      else if (this_AlfrescoUtil.hasOwnProperty("page") && page.url.args[name] && page.url.args[name].length != 0)
      {
         value = page.url.args[name];
      }
      else if (this_AlfrescoUtil.hasOwnProperty("page") && page.url.templateArgs[name] && page.url.templateArgs[name].length != 0)
      {
         value = page.url.templateArgs[name];
      }
      else if (this_AlfrescoUtil.hasOwnProperty("template") && template.properties[name] && template.properties[name].length != 0)
      {
         value = template.properties[name];
      }
      else if (arguments.length > 1)
      {
         value = defaultValue;
      }
      else
      {
         AlfrescoUtil.error(400, 'Parameter "' + name+ '" is missing.', true);
      }
      model[name] = value;
      return value;
   },
   getMetaData: function getMetaData(nodeRef, defaultValue)
   {
      var result = remote.connect("alfresco").get('/api/metadata?nodeRef=' + nodeRef);
      if (result.status != 200)
      {
         if (defaultValue !== undefined)
         {
            return defaultValue;
         }
         AlfrescoUtil.error(result.status, 'Could not load meta data ' + nodeRef);
      }
      result = eval('(' + result + ')');
      return result;
   },
};
05-23-2012 11:25 AM
05-23-2012 11:37 AM
05-23-2012 12:10 PM
05-24-2012 10:30 AM
04240078 Wrapped Exception (with status template): 04243325 Failed to execute script '/com/companyx/comments/comments-list.get.js (in repository store workspace://SpacesStore/Homepage dell'azienda/Dizionario dei dati/Web Script)': 04243324 Invalid node ref - does not contain forward slash: alfresco-util.jscalling the URL
<import resource="surf-doclist.lib.js">
var this_AlfrescoUtil = this;
var AlfrescoUtil =
{
   error: function error(code, message, redirect)
   {
      status.code = arguments.length > 0 ? 500 : code;
      status.message = message || 'An error occured';
      status.redirect = arguments.length > 2 ? redirect : true;
      throw new Error(message);
   },
   /**
    * Looks for a parameter in a "safe" way that works in all "environments".
    * Meaning it will look in "page" and "template" if they do exist and not fail /crash if they don't.
    *
    * Looks for an argument in the following order/locations:
    * 1. args[name]
    * 2. page.url.args[name]        
    * 3. page.url.templateArgs[name]
    * 4. template.properties[name]
    * 5. a) if defaultValue has been passed in that is used
    *    b) otherwise the parameter is treated as required and an error is thrown
    *
    * @param name
    * @param defaultValue
    * @return the value for the parameter
    */
   param: function param(name, defaultValue)
   {
      var value;
      if (name in url.templateArgs) value=url.templateArgs[name];
      // if (args[name] && args[name].length != 0)
      // {
      //    value = args[name];
      // }
      // else if (this_AlfrescoUtil.hasOwnProperty("page") && page.url.args[name] && page.url.args[name].length != 0)
      // {
      //    value = page.url.args[name];
      // }
      // else if (this_AlfrescoUtil.hasOwnProperty("page") && page.url.templateArgs[name] && page.url.templateArgs[name].length != 0)
      // {
      //    value = page.url.templateArgs[name];
      // }
      // else if (this_AlfrescoUtil.hasOwnProperty("template") && template.properties[name] && template.properties[name].length != 0)
      // {
      //    value = template.properties[name];
      // }
      else if (arguments.length > 1)
      {
         value = defaultValue;
      }
      else
      {
         AlfrescoUtil.error(400, 'Parameter "' + name+ '" is missing.', true);
      }
      model[name] = value;
      return value;
   },
   
   getRootNode: function getRootNode()
   {
      var rootNode = "alfresco://company/home",
         repoConfig = config.scoped["RepositoryLibrary"]["root-node"];
      if (repoConfig !== null)
      {
         rootNode = repoConfig.value;
      }
      return rootNode;
   },
    
   getNodeDetails: function getNodeDetails(nodeRef, site, options)
   {
     AlfrescoUtil.error(500, 'Noderef is '+nodeRef+' while site is '+site, true);
    return null;
      if (nodeRef)
      {
         var url = '/slingshot/doclib2/node/' + nodeRef.replace('://', '/');
         if (!site)
         {
            // Repository mode
            url += "?libraryRoot=" + encodeURIComponent(AlfrescoUtil.getRootNode());
         }
         var result = remote.connect("alfresco").get(url);
         if (result.status == 200)
         {
            var details = eval('(' + result + ')');
            if (details && (details.item || details.items))
            {
               DocList.processResult(details, options);
               return details;
            }
         }
      }
      return null;
   },
   
   getMetaData: function getMetaData(nodeRef, defaultValue)
   {
//   var result=search.findNode(nodeRef);
     var result = remote.connect("alfresco").get('/api/metadata?nodeRef=' + nodeRef);
      if (result.status != 200)
      {
         if (defaultValue !== undefined)
         {
            return defaultValue;
         }
         AlfrescoUtil.error(result.status, 'Could not load meta data ' + nodeRef);
      }
      result = eval('(' + result + ')');
      return result;
   },
};
<import resource="alfresco-util.js">
function getActivityParameters(nodeRef, defaultValue)
{
   var cm = "{http://www.alfresco.org/model/content/1.0}",
      metadata = AlfrescoUtil.getMetaData(nodeRef, {});
   if (metadata.properties)
   {
      if (model.activityType == "document")
      {
         return (
         {
            itemTitle: metadata.properties[cm + 'title'] || metadata.properties[cm + 'name'],
            page: 'document-details',
            pageParams:
            {
               nodeRef: metadata.nodeRef
            }
         });
      }
      else if (model.activityType == "folder")
      {
         return (
         {
            itemTitle: metadata.properties[cm + 'title'] || metadata.properties[cm + 'name'],
            page: 'folder-details',
            pageParams:
            {
               nodeRef: metadata.nodeRef
            }
         });
      }
      else if (model.activityType == "link")
      {
         var lm = "{http://www.alfresco.org/model/linksmodel/1.0}";
         return (
         {
            itemTitle: metadata.properties[lm + "title"],
            page: 'links-view',
            pageParams:
            {
               linkId: metadata.properties[cm + "name"]
            }
         });
      }
      else if (model.activityType == "blog")
      {
         return (
         {
            itemTitle: metadata.properties[cm + 'title'] || metadata.properties[cm + 'name'],
            page: 'blog-postview',
            pageParams:
            {
               postId: metadata.properties[cm + "name"]
            }
         });
      }
   }
   return defaultValue;
}
function main()
{
   // AlfrescoUtil.param('nodeRef', null);
   // AlfrescoUtil.param('site', null);
   // AlfrescoUtil.param('maxItems', 10);
   // AlfrescoUtil.param('activityType', null);
//   model.nodeRef = null;
     status.code=403;
     status.message='Unable to get nodeRef';
     status.redirect=true;
//   if (model.nodeRef) {
   // if (!model.nodeRef)
   // {
   //    // Handle urls that doesn't use nodeRef
   //    AlfrescoUtil.param('postId', null);
   //    if (model.postId)
   //    {
   //       // translate blog post "postId" to a nodeRef
   //       AlfrescoUtil.param('container', 'blog');
   //       model.nodeRef = AlfrescoUtil.getBlogPostDetailsByPostId(model.site, model.container, model.postId, {}).nodeRef;
   //    }
   //    else
   //    {
   //       AlfrescoUtil.param('linkId', null);
   //       if (model.linkId)
   //       {
   //          // translate link's "linkId" to a nodeRef
   //          AlfrescoUtil.param('container', 'links');
   //          model.nodeRef = AlfrescoUtil.getLinkDetailsByPostId(model.site, model.container, model.linkId, {}).nodeRef;
   //       }
   //    }
   // }
      
   //    var documentDetails = AlfrescoUtil.getNodeDetails(model.nodeRef, model.site);
   //    if (documentDetails)
   //    {
   //       var activityParameters = getActivityParameters(model.nodeRef, null);
   //       if (activityParameters)
   //       {
   //          model.activityParameterJSON = jsonUtils.toJSONString(activityParameters);
   //       }
   //    }
   // }
   //    else
   //    {
   //       // Signal to the template that the node doesn't exist and that comments therefore shouldn't be displayed.
   //       model.nodeRef = null;
   //   status.code=403;
   //   status.message='Unable to get nodeRef';
   //   status.redirect=true;
   //    }
}
main();
<webscript>
  <shortname>Comments component</shortname>
  <description>Displays comments for a node</description>
  <url>/com/companyx/components/comments/list</url>
  <transaction>required</transaction> 
  <authentication>user</authentication>
</webscript>
 
					
				
				
			
		
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.