AnsweredAssumed Answered

Alfresco 4.x Share custom page with Java backed script load

Question asked by m_scapoli on Apr 2, 2012
Latest reply on Apr 27, 2012 by m_scapoli
Hi there!

I'm trying, and partially done, to extend Alfresco 4.0c with an action that load a new page (in the style of alfresco's pages) and load a certain webscript that I have written but when I try to load the webscript I run into Web Script Status 500 - Internal Error

I was inspired by the DocumentGeographicDetails and with some "reverse engineering" I could create a new action and link that to a new page declaration, then I unsuccessful try to recall a Java backed Script (that it works when I call it separately) in a certain region <region-id>doclib-custom</region-id> at the end of  template-instances.xml

[img]http://desmond.imageshack.us/Himg801/scaled.php?server=801&filename=docdiffaction.png&res=medium[/img]

[img]http://desmond.imageshack.us/Himg99/scaled.php?server=99&filename=docdiffpage.png&res=medium[/img]

[img]http://desmond.imageshack.us/Himg338/scaled.php?server=338&filename=jsonresponse.png&res=medium[/img]

I've tryed to load the script in the <region-id>doclib-custom</region-id> at the end of  template-instances.xml
alfresco/web-extension/template-instances/document-diff.xml

<?xml version='1.0' encoding='UTF-8'?>
<template-instance>
   <template-type>org/alfresco/document-details</template-type>
   <properties>
      <pageFamily>documentlibrary</pageFamily>
      <container>documentLibrary</container>
   </properties>
   <components>

      <!– Title –>
      <component>
         <region-id>title</region-id>
         <sub-components>
            <sub-component id="default">
                               …
                               …
                               …

      <!– Custom Component –>
      <component>
         <region-id>doclib-custom</region-id>
         <url>/components/diffhook</url>
         <!–<url>/components/documentlibrary/doclib-custom</url>–>
      </component>

   </components>
</template-instance>

alfresco/web-extension/site-webscripts/ext/documentdiff/components/diffhook.get.desc.xml

<webscript>
   <shortname>Document Diff Hook</shortname>
   <description>document-diff hook for declarative.json</description>
   <family>family_docdiff_hook</family>
   <url>/components/diffhook</url>
</webscript>
alfresco/web-extension/site-webscripts/ext/documentdiff/components/diffhook.get.html.ftl
<div>${diffhook.msg}</div>
the .msg try to hook at the repo-extension project that is simply the Simple Declarative Web Script Project from the Java backed Wiki page…
alfresco/web-extension/site-webscripts/ext/documentdiff/components/diffhook.get.js

var connector = remote.connect("alfresco/service");
var data = connector.get("/documentdiff/declarative.json");

// create json object from data
var result = eval('(' + data + ')');
model.diffhook = result["declarative"];

I also tryed to work adding additional region with the <@region> directive as it is written in the David Draper's - Customizing Alfresco Share FreeMarker Templates but without results. I tryed to recall the same "Hello World" script code in my custom page above under the node-header region with this code but don't work

alfresco/web-extension/site-data/extensions/docdiff-extension.xml

<module>
    <id>Blog Module (Add Region)</id>
    <customizations>
        <customization>
            <targetPackageRoot>org.alfresco</targetPackageRoot>
            <sourcePackageRoot>blog.demo.customization</sourcePackageRoot>
        </customization>
    </customizations>
</module>
alfresco/templates/blog/demo/customization/document-details.ftl

<@region id="additional-content" target="node-header" action="after" scope="global" />
alfresco/web-extension/site-data/components/global.additional-content.xml

<component>
    <region-id>additional-content</region-id>
    <source-id>global</source-id>
    <scope>global</scope>
    <uri>/blog/demo/new-content</uri>
</component>

certainly is my fault but the poor documentation and the wiki are of little help, thanks in advance to anyone responding to the question

Regards

Outcomes