Extension Point: Surf Extension Modules
Description:
This tutorial demonstrates how to customize the WebView dashlet web script controller so the Alfresco Home page is displayed by default. The tutorial walks through how to find the related component and web script.
Implementation Steps:
It is often necessary to customize different parts of a Surf web script. This tutorial shows you how to customize the controller for a web script. The approach looks something like this:
- Find the page component that corresponds to the content that should be changed.
- Identify the web script that is used to deliver the content.
- Identify what part of the web script need changing to achieve the customization, in this case the controller as we can set the page that should be loaded by default in the model.
- Create your version of the {web script id}.get.js file.
- Use a Surf Extension module to define the web script override.
Related Information:
This tutorial assumes that you are familiar with the Spring Surf development framework.
Source Code: Go to code
This tutorial assumes you have created a new SDK All-In-One project.
Tutorial implementation steps:
The custom JavaScript is executed after the original. The original JavaScript sets up an initial model object, which the default FreeMarker template can use to render content. Controller extensions then have the opportunity to change that model and thus change the rendered output. Using this approach is dependent upon the template making use of the changed model content - just adding content to the model will have no effect unless the template is also updated to make use of the additional model data.
It is not always possible to use this approach to customize existing components, as it depends on how the JavaScript controller and template are implemented, but the approach is worth exploring.