Access to JavaScript API from .ftl
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2009 04:42 PM
Hi all,
I want to know if the user that is currently executing the webscript has "Write" permission over some folder.
Here is some code of I would like to do (FTL):
Of course this code does not work (syntax error on child.hasPermission), but I cannot figure out of what should I do in order to know if the user can or cannot write on a folder.
I've tried to itearate over the "nodes" array that I'm using on the FTL and manually set a custom property that tell me if the user can write on the folder, here's the code:
But the problem is that if the user cannot write on a folder (I mean the user has no write permissions) the line "child.properties.readOnly = …" won't work. Actually I'm getting an error in the FTL that tells me that the property readOnly doesn't exists if the user cannot write in the folder, but the scripts works fine if he can write on the them.
What can I do? Any ideas?
Thanks!
I want to know if the user that is currently executing the webscript has "Write" permission over some folder.
Here is some code of I would like to do (FTL):
<folderStructure> <rootName><![CDATA[${rootName}]]></rootName> <rootChildren> <#list nodes as child> <child> <name><![CDATA[${child.name}]]></name> <readOnly><![CDATA[${ child.hasPermission("Write") }]]></readOnly> </child> </#list> </rootChildren></folderStructure>
Of course this code does not work (syntax error on child.hasPermission), but I cannot figure out of what should I do in order to know if the user can or cannot write on a folder.
I've tried to itearate over the "nodes" array that I'm using on the FTL and manually set a custom property that tell me if the user can write on the folder, here's the code:
for each (var child in children) { logger.log(child.name + " : " + child.hasPermission("Write")); child.properties.readOnly = !child.hasPermission("Write"); } model.nodes = children;
But the problem is that if the user cannot write on a folder (I mean the user has no write permissions) the line "child.properties.readOnly = …" won't work. Actually I'm getting an error in the FTL that tells me that the property readOnly doesn't exists if the user cannot write in the folder, but the scripts works fine if he can write on the them.
What can I do? Any ideas?
Thanks!
Labels:
- Labels:
-
Archive
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2009 05:08 PM
Freemarker tends to want strings in situations like that, so try:
Thanks,
Mike
child.hasPermission("Write")?string
Thanks,
Mike
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2009 06:27 AM
Thanks a lot! It works!

