cancel
Showing results for 
Search instead for 
Did you mean: 

roothome.childByNamePath()

koolalfdev
Champ in-the-making
Champ in-the-making
Hello All,

I have my web scripts in the classpath:alfresco/extension/templates/webscripts/myWebscripts.

I have a java script file test.get.js that creates an object and sets it in the model.data = "testData". I want to call the node.processTemplate(template) and the ftl file is in the same directory but when I do   var temp = roothome.childByNamePath(alfresco/extension/templates/webscripts/myWebscripts/test.ftl) it returns null.

Kindly help I have deliverable coming up this Friday Smiley Happy

Thanks
2 REPLIES 2

sbuckle
Champ in-the-making
Champ in-the-making
I don't think it's possible to do what you are trying, e.g. get a node reference to a file that resides on the file system.

As a last resort you could always put your Freemarker templates / JavaScript files in the repo itself, e.g. Data Dictionary -> Web Scripts, and then use childByNamePath(…) For example:


var node = companyhome.childByNamePath("Data Dictionary/Web Scripts/test.ftl");

ivo_costa
Champ in-the-making
Champ in-the-making
hi koolalfdev

I also tried to use the similar function (getChildByName) in a java project I had and no mater what I tried I always got null as a result
the only solution I found was to execute a lucene query for the exact path+filename and get the first node on the result array

as seen below in the Java example

      String query = "+PATH:\"app:company_home/app:dictionary/app:email_templates/cm:template.ftl\"";
      SearchService searchService = serviceRegistry.getSearchService();
      StoreRef storeRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE,
            "SpacesStore");
      ResultSet resultSet = searchService.query(storeRef,
            SearchService.LANGUAGE_LUCENE, query);
      NodeRef template = resultSet.getNodeRef(0);

hope this helps you

regards

Ivo Costa
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.