public abstract class AbstractRenderer extends Object implements Renderer, RenderingModelBasedRenderer
Modifier and Type | Field and Description |
---|---|
protected static String |
MODEL_ATTRIBUTE |
Constructor and Description |
---|
AbstractRenderer()
Deprecated.
since 5.0.2, use
AbstractRenderer(RenderingEngine) |
AbstractRenderer(RenderingEngine renderingEngine) |
Modifier and Type | Method and Description |
---|---|
void |
addContextAttribute(String name,
ContextAttributeConfiguration contextAttributeConfiguration) |
protected AggregationState |
getAggregationStateSafely()
This gets the aggregation state without throwing an exception if the current context is not a WebContext.
|
Map<String,ContextAttributeConfiguration> |
getContextAttributes() |
protected javax.jcr.Node |
getMainContentSafely(javax.jcr.Node content)
Gets the current main content or returns null if aggregation state is not set.
|
protected abstract Map<String,Object> |
newContext()
Create a new context object which is a map.
|
protected <T extends RenderingModel<?>> |
newModel(Class<T> modelClass,
javax.jcr.Node content,
RenderableDefinition definition,
RenderingModel<?> parentModel) |
RenderingModel<?> |
newModel(javax.jcr.Node content,
RenderableDefinition definition,
RenderingModel<?> parentModel)
Instantiates the model based on the class defined by the
RenderableDefinition.getModelClass() property. |
protected abstract void |
onRender(javax.jcr.Node content,
RenderableDefinition definition,
RenderingContext renderingCtx,
Map<String,Object> ctx,
String templateScript)
Finally execute the rendering.
|
void |
render(RenderingContext renderingCtx,
Map<String,Object> contextObjects)
Called by
RenderingEngine after it has setup the RenderingContext . |
protected String |
resolveTemplateScript(javax.jcr.Node content,
RenderableDefinition definition,
RenderingModel<?> model,
String actionResult)
Hook-method to be overriden when required.
|
protected void |
restoreContext(Map<String,Object> ctx,
Map<String,Object> state) |
protected void |
saveAttribute(Map<String,Object> ctx,
Map<String,Object> state,
String name) |
protected Map<String,Object> |
saveContextState(Map<String,Object> ctx) |
protected Object |
setContextAttribute(Map<String,Object> ctx,
String name,
Object value) |
void |
setContextAttributes(Map<String,ContextAttributeConfiguration> contextAttributes) |
protected void |
setupContext(Map<String,Object> ctx,
javax.jcr.Node content,
RenderableDefinition definition,
RenderingModel<?> model,
Object actionResult) |
protected javax.jcr.Node |
wrapNodeForModel(javax.jcr.Node content)
Wraps the current content node before passing it to the model.
|
protected javax.jcr.Node |
wrapNodeForTemplate(javax.jcr.Node content)
Wraps the current content node for exposing it to the template script as a context attribute.
|
protected static final String MODEL_ATTRIBUTE
public AbstractRenderer()
AbstractRenderer(RenderingEngine)
@Inject public AbstractRenderer(RenderingEngine renderingEngine)
public void render(RenderingContext renderingCtx, Map<String,Object> contextObjects) throws RenderException
Renderer
RenderingEngine
after it has setup the RenderingContext
.render
in interface Renderer
renderingCtx
- rendering context prepared by the callercontextObjects
- objects to expose to the template scriptRenderException
protected String resolveTemplateScript(javax.jcr.Node content, RenderableDefinition definition, RenderingModel<?> model, String actionResult)
definition
- reference templateScript is retrieved frompublic RenderingModel<?> newModel(javax.jcr.Node content, RenderableDefinition definition, RenderingModel<?> parentModel) throws RenderException
RenderableDefinition.getModelClass()
property. All the request
parameters are then mapped to the model's properties.newModel
in interface RenderingModelBasedRenderer
RenderException
protected <T extends RenderingModel<?>> T newModel(Class<T> modelClass, javax.jcr.Node content, RenderableDefinition definition, RenderingModel<?> parentModel) throws RenderException
RenderException
protected void saveAttribute(Map<String,Object> ctx, Map<String,Object> state, String name)
protected void setupContext(Map<String,Object> ctx, javax.jcr.Node content, RenderableDefinition definition, RenderingModel<?> model, Object actionResult)
protected javax.jcr.Node getMainContentSafely(javax.jcr.Node content)
protected AggregationState getAggregationStateSafely()
protected javax.jcr.Node wrapNodeForModel(javax.jcr.Node content)
content
- the actual contentprotected javax.jcr.Node wrapNodeForTemplate(javax.jcr.Node content)
content
- the actual contentprotected Object setContextAttribute(Map<String,Object> ctx, String name, Object value)
public Map<String,ContextAttributeConfiguration> getContextAttributes()
public void setContextAttributes(Map<String,ContextAttributeConfiguration> contextAttributes)
public void addContextAttribute(String name, ContextAttributeConfiguration contextAttributeConfiguration)
protected abstract Map<String,Object> newContext()
protected abstract void onRender(javax.jcr.Node content, RenderableDefinition definition, RenderingContext renderingCtx, Map<String,Object> ctx, String templateScript) throws RenderException
RenderException
Copyright © 2003–2015 Magnolia International Ltd.. All rights reserved.