Config Object - Alfresco Content Services - 23.4 - 23.4 - Ready - Alfresco - external

Alfresco Content Services

Platform
Alfresco
Product
Alfresco Content Services
Release
23.4
License

The configuration object contains component configuration in XML format.

Each component can have a snippet of XML configuration associated with it. The configuration can be any XML content and should be placed within a file named <yourcomponent>.<method>.config.xml. This object provides access to either the XML text content (for script model) or XML DOM (for FreeMarker template model) within the configuration.

For JavaScript access, the most common mechanism to process the XML config is to use the E4X XML DOM object.

For example, given the following XML configuration file filters.get.config.xml:

<filters>
   <filter id="all" label="All" />
   <filter id="new" label="New" />
   <filter id="drafts" label="Drafts" />
</filters>

Would be retrieved by using the config .script accessor and processed in JavaScript:

var cfg = new XML(config.script);
   for each(var filter in cfg..filter)
   {
      var id = filter.@id.toString();
      var label: filter.@label.toString();
      // do some work with the values
   }

Within a FreeMarker template the built-in XML DOM node object can be used. For example:

<#listconfig.script["filters"]["filter"].@idasf>${f}</#list>

The application global configuration and scoped configuration can be accessed by using the global and scoped accessors.

For example:

<#assignhelpPages = config.scoped["HelpPages"]["help-pages"]>
<#-- Global flags retrieved from web-framework-config-application -->
<#assign DEBUG=(config.global.flags.childrenMap["client-debug"][0].value = "true")>

See the online FreeMarker documentation for more information on XML DOM processing.