cancel
Showing results for 
Search instead for 
Did you mean: 

I believe everything you need is already in HEAD.Here's...

davidc
Star Contributor
Star Contributor
I believe everything you need is already in HEAD.

Here's the full Web Script for displaying the name of the node as specified by its node reference on the url.  Add the following three files to your web scripts folder…

example.get.desc.xml


<webscript>
  <shortname>Search example</shortname>
  <description>Demonstrate use of javascript search api</description>
  <url format="html" template="/showname?noderef={noderef}"/>
  <authentication>user</authentication>
</webscript>

example.get.js


// use the javascript search api to get the node for the noderef argument
var node = search.findNode(args.noderef);

// setup model for template to render
model.node_that_has_been_found = node;

example.get.html.ftl


<html>
  <body>
     <#if node_that_has_been_found?exists>
       Name of node ${args.noderef} is ${node_that_has_been_found.name}.
     <#else>
       Node ${args.noderef} does not exist.
     </#if>
  </body>
</html>

You can then issue the URL…

http://localhost:8080/alfresco/service/showname?noderef=workspace://SpacesStore/cb7c90ec-0dcc-11dc-8...

for a node in your repository (use the Node Browser to get a noderef).

Basically, if you add a javascript file, it will be executed before the template.  The full javascript api is available.  You can populate the special 'model' object with named values which are then accessible in the template e.g. node_that_has_been_found in the above example.
2 REPLIES 2

tak
Champ in-the-making
Champ in-the-making
Hi,

I have a similar question  about nodeRef and javascript.

(1) search.findNode(<nodeRef string>) works only when the lucene search is completed? Or the contents with this nodeRef is alive, find method returns node object with no exception?

(2) Can search.findNode(<nodeRef string>) find the node of past versioned content with versionable aspect?
The form of nodeRef string of This past versioned content is "ersionStore://lightWeightVersionStore/xxxxxxxx"

davidc
Star Contributor
Star Contributor
(1) search.findNode(<nodeRef string>) works only when the lucene search is completed? Or the contents with this nodeRef is alive, find method returns node object with no exception?

Not sure what you mean, but findNode only returns a result upon completion of the search.  If the node is not found, null is returned.

(2) Can search.findNode(<nodeRef string>) find the node of past versioned content with versionable aspect?
The form of nodeRef string of This past versioned content is "ersionStore://lightWeightVersionStore/xxxxxxxx"

No, the current javascript search api is restricted to the Spaces store.  You could introduce your own search root object hooked into the version store - see script-services-context.xml.
Getting started

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.