org.apache.tiles.renderer.impl
Class AbstractBaseAttributeRenderer

Package class diagram package AbstractBaseAttributeRenderer
java.lang.Object
  extended by org.apache.tiles.renderer.impl.AbstractBaseAttributeRenderer
All Implemented Interfaces:
TilesApplicationContextAware, TilesContextFactoryAware, AttributeEvaluatorAware, AttributeRenderer
Direct Known Subclasses:
DefinitionAttributeRenderer, StringAttributeRenderer, TemplateAttributeRenderer, UntypedAttributeRenderer

public abstract class AbstractBaseAttributeRenderer
extends java.lang.Object
implements AttributeRenderer, TilesContextFactoryAware, TilesApplicationContextAware, AttributeEvaluatorAware

Base abstract class that manages authorization to display the attribute.

Since:
2.1.0

Field Summary
protected  TilesApplicationContext applicationContext
          The Tiles application context.
protected  TilesContextFactory contextFactory
          The Tiles context factory.
protected  AttributeEvaluator evaluator
          The attribute evaluator.
 
Constructor Summary
AbstractBaseAttributeRenderer()
           
 
Method Summary
protected  TilesRequestContext getRequestContext(java.lang.Object... requestItems)
          Creates a Tiles request context from request items.
protected  boolean isPermitted(TilesRequestContext request, java.util.Set<java.lang.String> roles)
          Checks if the current user is in one of the comma-separated roles specified in the role parameter.
 void render(Attribute attribute, java.io.Writer writer, java.lang.Object... requestItems)
          Renders an attribute.
 void setApplicationContext(TilesApplicationContext applicationContext)
          Sets the Tiles application context.
 void setContextFactory(TilesContextFactory contextFactory)
          Sets the Tiles context factory.
 void setEvaluator(AttributeEvaluator evaluator)
          Sets the evaluator.
abstract  void write(java.lang.Object value, Attribute attribute, java.io.Writer writer, TilesRequestContext request, java.lang.Object... requestItems)
          Implement this method knowing that the attribute won't be null and it will be authorized.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

contextFactory

protected TilesContextFactory contextFactory
The Tiles context factory.

Since:
2.1.0

applicationContext

protected TilesApplicationContext applicationContext
The Tiles application context.

Since:
2.1.0

evaluator

protected AttributeEvaluator evaluator
The attribute evaluator.

Since:
2.1.0
Constructor Detail

AbstractBaseAttributeRenderer

public AbstractBaseAttributeRenderer()
Method Detail

setContextFactory

public void setContextFactory(TilesContextFactory contextFactory)
Sets the Tiles context factory.

Specified by:
setContextFactory in interface TilesContextFactoryAware
Parameters:
contextFactory - The Tiles context factory.

setApplicationContext

public void setApplicationContext(TilesApplicationContext applicationContext)
Sets the Tiles application context.

Specified by:
setApplicationContext in interface TilesApplicationContextAware
Parameters:
applicationContext - The Tiles application context.

setEvaluator

public void setEvaluator(AttributeEvaluator evaluator)
Sets the evaluator.

Specified by:
setEvaluator in interface AttributeEvaluatorAware
Parameters:
evaluator - The evaluator to set.

render

public void render(Attribute attribute,
                   java.io.Writer writer,
                   java.lang.Object... requestItems)
            throws java.io.IOException
Renders an attribute.

Specified by:
render in interface AttributeRenderer
Parameters:
attribute - The attribute to render.
writer - The writer to use.
requestItems - The request items.
Throws:
java.io.IOException - If something goes wrong during rendition.

write

public abstract void write(java.lang.Object value,
                           Attribute attribute,
                           java.io.Writer writer,
                           TilesRequestContext request,
                           java.lang.Object... requestItems)
                    throws java.io.IOException
Implement this method knowing that the attribute won't be null and it will be authorized.

Parameters:
value - The value of the attribute to be rendered.
attribute - The attribute to render.
writer - The writer to use.
request - The Tiles request object.
requestItems - The original request items.
Throws:
java.io.IOException - If something goes wrong during rendition.
Since:
2.1.0

getRequestContext

protected TilesRequestContext getRequestContext(java.lang.Object... requestItems)
Creates a Tiles request context from request items.

Parameters:
requestItems - The request items.
Returns:
The created Tiles request context.
Since:
2.1.0

isPermitted

protected boolean isPermitted(TilesRequestContext request,
                              java.util.Set<java.lang.String> roles)
Checks if the current user is in one of the comma-separated roles specified in the role parameter.

Parameters:
request - The request context.
roles - The list of roles.
Returns:
true if the current user is in one of those roles.
Since:
2.1.0