Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.

CanvasLifecycleHandler Interface

Implement this interface to control context information and add custom behavior during the application render phase.

Namespace

Canvas

Usage

Use this interface to specify what canvas context information is provided to your app by implementing the excludeContextTypes() method. Use this interface to call custom code when the app is rendered by implementing the onRender() method.

If you provide an implementation of this interface, you must implement excludeContextTypes() and onRender().

Example Implementation

The following example shows a simple implementation of CanvasLifecycleHandler that specifies that organization context information will be excluded and prints a debug message when the app is rendered.
1public class MyCanvasListener 
2implements Canvas.CanvasLifecycleHandler{
3    public Set<Canvas.ContextTypeEnum> excludeContextTypes(){
4        Set<Canvas.ContextTypeEnum> excluded = new Set<Canvas.ContextTypeEnum>();
5        excluded.add(Canvas.ContextTypeEnum.ORGANIZATION);
6        return excluded;
7    }
8    
9    public void onRender(Canvas.RenderContext renderContext){
10        System.debug('Canvas lifecycle called.');
11    }
12}