Getting share hostname,port, context i javascript
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2010 09:43 AM
(Maybe this post is better fitted in the Javascript API forum, but that subforum was locked for me)
I have changed the CIFS javascript action __showDetails to link to Share instead. And that was a simple change (I can post how once it is complete).
But I had to hard code the share server name, port and context. I want this be configurable, or read from the setting in alfresco-global.properties (share.host, share.port etc).
I found the projects/repository/source/java/org/alfresco/repo/jscript/ScriptUrls.java, and assumed this could be accessed in javascript. But there seem to be no base object for this. Looking at org.alfresco.repo.processor.ScriptServiceImpl.java, it looks like there should be a base object "urls" for this, but it is not available i a desktop action javascript. Also tested "urls" in a webscript, and it didn't work there either.
So how can I get the config value for Share hostname, port and context?
I have changed the CIFS javascript action __showDetails to link to Share instead. And that was a simple change (I can post how once it is complete).
But I had to hard code the share server name, port and context. I want this be configurable, or read from the setting in alfresco-global.properties (share.host, share.port etc).
I found the projects/repository/source/java/org/alfresco/repo/jscript/ScriptUrls.java, and assumed this could be accessed in javascript. But there seem to be no base object for this. Looking at org.alfresco.repo.processor.ScriptServiceImpl.java, it looks like there should be a base object "urls" for this, but it is not available i a desktop action javascript. Also tested "urls" in a webscript, and it didn't work there either.
So how can I get the config value for Share hostname, port and context?
Labels:
- Labels:
-
Archive
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2010 09:00 AM
An alternative approach would be to create a scoped config variable which is accessible from javascript and Freemarker. See http://wiki.alfresco.com/wiki/Web_Scripts#Global_and_Scoped_Config In webscript-framework-config-custom.xml create your own section (don't use the tag <server> since it is reserved). Try something like <shareserver>. Use the generic access method.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2010 09:43 AM
Thanks, that approach is however only available to webscripts. For this particular case, it is javascript for cifs desktop actions. It doesn't even have the root scoped objects like companyhome available.
I resolved it by
I resolved it by
var companyhome = search.findNode("path", ['workspace','SpacesStore','app:company_home']);var shareurlsetting = companyhome.childByNamePath('/Data Dictionary/Loftux/ShareUrl');if(shareurlsetting!=null){ var servercontext = shareurlsetting.properties["title"];}else{ var servercontext = "http://localhost:8080/share"}
The object ShareUrl is just a content less file i space "Loftux", where I use title to store my setting. Note how I had to create my own companyhome object.
