Alfresco 5: using just only

Deploying Alfresco artifacts in several environments requires different parameters in configuration files.

Some time ago I was working with Alfresco in a maven way: packaging properties together with the artifact by using profiles. This method requires several packagings for the same module: one for each environment.

Alfresco experienced developers, and alfresco documentation itself, are suggesting to include module properties just only in for repo artifacts and in share-config-custom.xml for share artifacts.

However, this is one more file than required. Let me share with you how to use for share modules with the following example.


Including properties values in


Repo project

Exposing these properties as a REST service.

1. Describing the REST service

  <shortname>Get header params</shortname>
  <description>Get header params
  To test: curl -v -u "http://localhost:8080/alfresco/service/keensoft/header/params"
  <format default="json"/>

2. Declaring Spring bean for the Web Script

<!-- Return params from -->
<bean id="" 
      class="es.keensoft.alfresco.action.webscript.HeaderParamsWebScript" parent="webscript">
	<property name="url" value="${customHeaderModule.url}" />
    <property name="height" value="${customHeaderModule.height}"/>

3. Implementing logic for the service

package es.keensoft.alfresco.action.webscript;


import org.json.simple.JSONObject;
import org.springframework.extensions.webscripts.AbstractWebScript;
import org.springframework.extensions.webscripts.WebScriptRequest;
import org.springframework.extensions.webscripts.WebScriptResponse;
import org.springframework.http.MediaType;

public class HeaderParamsWebScript  extends AbstractWebScript {
	private String url;
	private String height;
	public void execute(WebScriptRequest request, WebScriptResponse response) throws IOException {
		JSONObject obj = new JSONObject();
		obj.put("customHeaderModuleHeight", height);
		obj.put("customHeaderModuleUrl", url);
    	String jsonString = obj.toString();

	public void setUrl(String url) {
		this.url = url;

	public void setHeight(String height) {
		this.height = height;


Share project

Recovering value by using Alfresco REST API.

1. Declaring Surf customization

      <id>Custom Header</id>

2. Recovering values from REST service

function main() {
	var headerParams = jsonConnection("/keensoft/header/params");
	model.url = headerParams.customHeaderModuleUrl;
	model.height = headerParams.customHeaderModuleHeight;


function jsonConnection(url) {
	var connector = remote.connect("alfresco"),
		result = connector.get(url);

	if (result.status == 200) {		
		return eval('(' + result + ')')
	} else {
		return null;

3. Extending view by using FTL

<@markup id="custom-header-resources" action="before" target="html">
	<iframe id="ifHeader" name="ifHeader" scrolling="auto" frameborder="0"


A new header is showed above original Alfresco header. Url and height parameters are recovered from




Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de

Estás comentando usando tu cuenta de Cerrar sesión /  Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión /  Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión /  Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión /  Cambiar )

Conectando a %s