The properties in alfresco-global.properties file are only
accessible from code within the Alfresco Repository classpath. These properties
cannot be directly accessed from Share Web Scripts or YUI client code.
The examples on the Web show you how to access these properties
using a custom repo Java bean but there is a way to access these properties without
writing any custom Java code. You can access these properties using a
Javascript backed repo Web Script.
In the JavaScript backed webscript first get the Spring root
web application context. After getting the Spring root web application context get
the instance of the “global-properties” bean from it. The “global-properties”
bean is a java.util.Properties type so now the repo Web Script should be able
to access all the properties from the alfresco-global.properties file.
The Javascript backed repo Web Script can now expose or return
these property values from alfresco-global.properties file. The repo Web Script returns the data as JSON.
Share Web Scripts and the YUI client can now access these
properties defined in alfresco-global.properties file by calling the Javascript
backed repo Web Script.
var url =
"/api/formtek/edm/get-default-preview-option";
var result =
remote.connect("alfresco").get(url);
if (result.status == 200)
{
model.previewOptionValue = JSON.parse(result).defaultPreviewOptionValue;
}
Alfresco.util.Ajax.jsonRequest(
{
method:
Alfresco.util.Ajax.GET,
requestContentType:
Alfresco.util.Ajax.JSON,
url:
Alfresco.constants.PROXY_URI + "api/formtek/edm/get-default-preview-option,
},
scope: this
},
failureCallback: {
fn: function (res) {
},
scope: this
}
});
No comments:
Post a Comment