Extension Point: Surf Extension Modules
Description:
This tutorial demonstrates how to prevent content from being rendered in a Surf page. This tutorial also shows how to use evaluations to decide whether content should be rendered or not.
Implementation Steps:
A simple and effective way to remove content from a Surf page is to follow these steps:
- Locate the component that corresponds to the content you want to remove from the page.
- Make a note of the region-id, source-id, and scope information for the component.
- Override the component definition and add an evaluator that resolves to not rendering the component.
- Use a Surf Extension module to deploy the overridden component definition.
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:
Further information
Some features introduced in this tutorial are explained in more detail in the following sections:
Parametrized source-id mapping: Every Share user gets their own dashboard page, which enables them to customize the layout to suit their own needs, but each user dashboard is generated from a single preset. In this tutorial you specify user/{userid}/dashboard. Note the use of the userid variable. This allows you to change the appearance of the dashboard for any user, not just the admin user.
Extending existing sub-components: When the dashboard pages were first created, the concept of sub-components in Surf did not exist. Consequently, if you search through the existing dashboard configuration files you will not find sub-components specified. Surf automatically converts these “legacy” components into the new extensible components containing a single sub-component with the ID “default”.
This allows you to add new content to these legacy components through sub-components, or customize the original content without affecting any new content. In the previous configuration XML, you can change the behavior of the components through modification of the default sub-component.
Note that multiple modules can extend the same component, which is why the deployment order of modules is important.
Sub-component evaluations: Every sub-component can optionally have zero or more evaluations. Each evaluation acts like an AND gate to a series of evaluators where an evaluation is considered successful if no evaluators fail. If an evaluation contains no evaluators, it is still considered to have evaluated successfully because nothing has failed.
The purpose of an evaluation is to change the behavior of a sub-component in one of three ways:
- Change the Web Script that renders the content by specifying a new URL.
- Change the default properties (and/or provide new properties) that are passed to the Web Script.
- Control whether or not the sub-component is actually rendered.
In this example, you are simply overriding the default behavior of the sub-component to prevent it from rendering by setting the <render> element to have a value of false (this defaults to true) if not defined.