Newer Version Available

This content describes an older version of this product. View Latest

Server-Side Rendering to the DOM

The Aura rendering service takes in-memory component state and updates the component in the Document Object Model (DOM).

The DOM is the language-independent model for representing and interacting with objects in HTML and XML documents. Aura automatically renders your components so you don't have to know anything more about rendering unless you need to customize the default rendering behavior for a component.

The preferred way to customize component rendering is to use a client-side renderer. You can also use a server-side renderer but it's not recommended as they don't degrade gracefully if an error, such as a network connection outage, occurs. The framework uses a server-side renderer to render an app's template and that is the primary use case for rendering on the server.

Note

Creating a Java Server-Side Renderer

If you've exhausted the alternatives, including a client-side renderer, create a server-side renderer in Java by implementing the org.auraframework.def.Renderer interface. The interface contains one method:

1swfobject.registerObject("clippy.codeblock-0", "9");public void render(BaseComponent<?,?> component, Appendable appendable)
2        throws IOException, QuickFixException;

The component argument is the instance to render. The appendable argument is the output buffer.

The class that implements the interface must have a no-argument constructor. The class is instantiated as a singleton, so no state should be stored in it.

Wiring Up a Server-Side Renderer

To wire up a server-side renderer for a component, add a renderer system attribute in <aura:component>. For example:

1swfobject.registerObject("clippy.codeblock-1", "9");<aura:component renderer="java://org.auraframework.demo.notes.renderers.ReallyNeedAServerSideRenderer">
2    ...
3</aura:component>

The framework behavior is undefined if you add a server-side renderer that also includes a client-side renderer. We recommend that you use one or the other.