Alfresco: extending Aikau pages using Aikau services

Alfresco official documentation, which lives in , has been expanded during the last year and nowadays, it contains detailed information on many technical topics.

One of these topics is Alfresco Share extension, including different extension techniques such as Surf Pages, Aikau Surf Pages, Aikau widgets, Web Scripts, Spring Surf extensions and Dashlets.

Recently, I’ve been working on an addon in order to allow Site Manager to set any page as Site Home Page. Besides other well known extension techniques, I’ve used the new Aikau framework to develop some part of my code.

Below my lessons learned are exposed.



Configuring Aikau services for a module

In order to get our Aikau service available in Share Header extension, it’s required to declare it at module extension section site-home-page-extension.xml

            <id>Select home page for Site</id>
            <!-- Declare Aikau service -->  
                <config evaluator="string-compare" condition="WebFramework" replace="false">
                                <package name="sitehomepage" location="js/keensoft/sitehomepage"/>
            <!-- Share header extension -->

Developing an Aikau service

The dojo based definition is included in a new file, called SiteHomePageService.js, stored at js/keensoft/sitehomepage, which is the identifier used on the location tag in previous Aikau service configuration.

In my case, URL page selected by the user must be sent to a Repo Web Script, so I have to use XHR module.

        function(declare, AlfCore, AlfXhr, xhr, JSON, lang, dom, domAttr, domClass, AlfConstants) {

   return declare([AlfCore, AlfXhr], {

      onSetCurrentPageAsHome:  function share_services_SiteHomePageService__onSetCurrentPageAsHome(publishPayload) {
         if (publishPayload && publishPayload.servletContext) {
            // Get current page
            var currentPage = window.location.href;
            currentPage = currentPage.replace(window.location.origin + publishPayload.servletContext, "/page");
            // Send current page to custom Repo Web Script
               url: AlfConstants.PROXY_URI + "keensoft/site/home/" + currentPage,
               method: "POST",
               data: {},
               successCallback: this.onSetHomePageSucess,
               callbackScope: this
           // Publish event
           this.alfPublish(this.setSiteHomePageTopic, { homePage: currentPage });


Extending an Aikau page

Once the extension is declared and the Aikau service is available, Aikau page extension can be performed. As my new link (“Use current page”) is at Share Header, I have to extend share-header.get.js Alfresco page.

// Find dropdown menu in Share Site header
var siteConfig = widgetUtils.findObject(model.jsonModel, "id", "HEADER_SITE_CONFIGURATION_DROPDOWN");

if (siteConfig != null) {
    // Repo Web Script invocation to determine if current user is Site Manager
    var userIsSiteManager = false, obj = null;
    json ="/api/sites/" + + "/memberships/" + encodeURIComponent(;
    if (json.status == 200) {
       obj = JSON.parse(json);
    if (obj) {
       userIsSiteManager = obj.role == "SiteManager";

    if (userIsSiteManager) {
        // Include our new Aikau Service"sitehomepage/SiteHomePageService");
        // Include our new Aikau Component
            name : "alfresco/menus/AlfMenuGroup",
            config :
                // Separator
                label: "Home page",
                        // Link to set current page as Site Home Page
                        id : "HEADER_SITE_MENU_HOME_PAGE",
                        name : "alfresco/menus/AlfMenuItem",
                        config : {
                            id : "HEADER_SITE_MENU_SET_CURRENT_PAGE_AS_HOME",
                            label : "Use current page",
                            title: "Use current page",
                            iconAltText: "Use current page",
                            iconClass: "alf-edit-icon",
                            // The topic to be published, our Aikau service is also subscribed to it
                            publishTopic: "ALF_SET_CURRENT_PAGE_AS_SITE_HOME",
                            // Topic payload, current page
                            publishPayload: {
                               servletContext: page.url.servletContext


Aikau may appear a hard framework to learn; but improved Alfresco documentation, code samples extracted from Alfresco source code, the extended and detailed Aikau learning material and the fact that every day more and more Alfresco Share source code is based in Aikau should be enough to make the transition to this technology softer for Alfresco developers.

Remember that all this code is available as an Alfresco SDK 2.1 project at



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