cancel
Showing results for 
Search instead for 
Did you mean: 

Using a webscript to display space content within web client

chrisb
Champ in-the-making
Champ in-the-making
We have been looking at some of the new for 2.1 webscript functionality.

I know its possible to use web scripts to generate a custom GUI for accessing the alfresco repository. Can webscript be used to render content for a space within the web client though?

For example can you use / call a webscript to display information in a space (similar to the way a freemarker template can currently be used to render space content in a custom format)?

If so how would you go about hooking using a webscript in a space for displaying content?

Thanks
12 REPLIES 12

davidc
Star Contributor
Star Contributor
I've just tested with the latest HEAD.  The category sample is working, as well as the other two samples listed in http://wiki.alfresco.com/wiki/Web_Scripts_Examples

The code fix for

Failed to execute script 'workspace://SpacesStore//Company Home/Data Dictionary/Web Scripts/org/alfresco/sample/categorysearch.get.js': Node does not exist: workspace://SpacesStore//Company Home/Data Dictionary/Web Scripts/org/alfresco/sample/categorysearch.get.js

is in org.alfresco.web.scripts.ScriptProcessor - line 108 - it should read:

        return scriptService.executeScript("javascript", location, model);        

before it was:

        return scriptService.executeScript(location, model);        

garpinc
Champ in-the-making
Champ in-the-making
Testing with head works… I just did full compile.. This indicates to me that nightly build is broken because it does not work.

Also on testing folder sample I attempted to browse AVM content. It still looks like this is not possible because I'm getting a NullPointerException

java.lang.NullPointerException  
   
org.alfresco.web.scripts.bean.ContentGet.execute(ContentGet.java:141) 
org.alfresco.web.scripts.WebScriptRuntime.wrappedExecute(WebScriptRuntime.java:336) 
org.alfresco.web.scripts.WebScriptRuntime.authenticatedExecute(WebScriptRuntime.java:302) 
org.alfresco.web.scripts.WebScriptRuntime$1.execute(WebScriptRuntime.java:159) 

1) What is the recomended way to browse AVM content using webscripts? Please provide example if you have one.

2) If this feature is not available yet when will it be available?

kevinr
Star Contributor
Star Contributor
The MySpaces portlet cannot browse AVM spaces.

The AVM API is supported for Template and Script engines in 2.1.

Here is an example of AVM template API usage that displays meta-data about an AVM store (specified as the 'store' argument to the template) and recursively lists the contents of the store in a table. It could easily be converted to a webscript:

<#assign mystore=avm.lookupStore(args["store"])>
<#if mystore?exists>
   Found store: ${mystore.name}
   <p>
   Store root node name: ${avm.lookupStoreRoot(args["store"]).name}
   <p>
   Store root node detail:<br>
    Info: ${mystore.lookupRoot}<br>
    Name: ${mystore.name}<br>
    Creator: ${mystore.creator}<br>
    Created Date: ${mystore.createdDate?datetime}
   <p>
   Store contents:<br>
   <table>
      <tr><th></th><th>Name</th><th>Path</th><th>Type</th><th>Parent</th><th>Created</th><th>Modified</th></tr>
      <@dir node=mystore.lookupRoot depth=0/>
   </table>
<#else>
   CANNOT FIND STORE: ${args["store"]}
</#if>

<#macro dir node depth>
   <#list node.children as c>
      <tr>
         <td width=16>
            <#if c.isDocument>
               <a href="${url.context}${c.url}" target="new"><img src="${url.context}${c.icon16}" alt="${c.name}" title="${c.name}" border=0></a>
            <#else>
               <img src="${url.context}${c.icon16}" alt="${c.name}" title="${c.name}" border=0>
            </#if>
         </td>
         <td>
            <font size='${4 - depth}'>${c.name}</div>
         </td>
         <td>
            ${c.path}
         </td>
         <td>
            ${c.type}
         </td>
         <td>
            ${c.properties.created?datetime}
         </td>
         <td>
            ${c.properties.modified?datetime}
         </td>
      </tr>
      <#if c.isContainer && c.children?size != 0>
         <@dir node=c depth=depth+1/>
      </#if>
   </#list>
</#macro>

Hope this helps,

Kevin