|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object info.magnolia.rendering.renderer.AbstractRenderer
public abstract class AbstractRenderer
Abstract renderer with support for typical functionality such as setting context attributes and executing a rendering model. Sets up the context by providing the following objects:
Field Summary | |
---|---|
protected static String |
MODEL_ATTRIBUTE
|
Constructor Summary | |
---|---|
AbstractRenderer()
|
Method Summary | ||
---|---|---|
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
|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final String MODEL_ATTRIBUTE
Constructor Detail |
---|
public AbstractRenderer()
Method Detail |
---|
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 script
RenderException
protected String resolveTemplateScript(javax.jcr.Node content, RenderableDefinition definition, RenderingModel<?> model, String actionResult)
definition
- reference templateScript is retrieved from
public 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 Map<String,Object> saveContextState(Map<String,Object> ctx)
protected void saveAttribute(Map<String,Object> ctx, Map<String,Object> state, String name)
protected void restoreContext(Map<String,Object> ctx, Map<String,Object> state)
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 content
protected javax.jcr.Node wrapNodeForTemplate(javax.jcr.Node content)
content
- the actual content
protected 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
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |