cancel
Showing results for 
Search instead for 
Did you mean: 

About WebScript

jeyush
Champ in-the-making
Champ in-the-making
I am new to the Alfresco. I am not able to understand how to use JAVA API for Alfresco.I know java very well.But I stuck in WebScript . Can anybody show me some coding part how to display content of particular file please?

Thanks in Advance.
3 REPLIES 3

mikeh
Star Contributor
Star Contributor
Hi

It depends what that file contains as to how you would display it in a browser, but here's a simple example taken from a part of the doclist portlet that ships with v2.1.

The code below assumes you've already got your document in a node variable, e.g. from a search.
<#assign isImage=node.isDocument && (node.mimetype = "image/gif" || node.mimetype = "image/jpeg" || node.mimetype = "image/png")>

<#if node.isDocument && !isImage>
   <#assign c=cropContent(node.properties.content, 2048)>
   <#if c?length != 0>
      ${c?html?replace('$', '<br>', 'rm')}<#if (c?length >= 2048)>…</#if>
   </#if>
<#elseif isImage>
   <a href="${url.context}${node.url}" target="new"><img src="${url.context}${node.url}?${node.size}" height="140" border="0"></a>
</#if>

Thanks,
Mike

jeyush
Champ in-the-making
Champ in-the-making
Thx for your time Mike.

kim
Champ in-the-making
Champ in-the-making
Hi Jeyush,

does this work for you? I always get an exception like
freemarker.core.InvalidReferenceException: Expression cropContent is undefined on line …
no matter if I run it as a web script, action (execute script…) or "Preview in template" in the web client.

Alfresco version is Community 2.9 B

Cheers,
Kim