org.apache.tiles.context
Class BasicComponentContext

Package class diagram package BasicComponentContext
java.lang.Object
  extended by org.apache.tiles.context.BasicComponentContext
All Implemented Interfaces:
java.io.Serializable, org.apache.tiles.ComponentContext

public class BasicComponentContext
extends java.lang.Object
implements org.apache.tiles.ComponentContext, java.io.Serializable

Component context.

See Also:
Serialized Form

Constructor Summary
BasicComponentContext()
          Constructor.
BasicComponentContext(org.apache.tiles.ComponentContext context)
           
BasicComponentContext(java.util.Map<java.lang.String,org.apache.tiles.ComponentAttribute> attributes)
          Constructor.
 
Method Summary
 void addAll(java.util.Map<java.lang.String,org.apache.tiles.ComponentAttribute> newAttributes)
          Add all attributes to this context.
 void addMissing(java.util.Map<java.lang.String,org.apache.tiles.ComponentAttribute> defaultAttributes)
          Add all missing attributes to this context.
 void clear()
           
 org.apache.tiles.ComponentAttribute findAttribute(java.lang.String beanName, javax.servlet.jsp.PageContext pageContext)
          Find object in one of the contexts.
 org.apache.tiles.ComponentAttribute getAttribute(java.lang.String name)
          Get an attribute from context.
 org.apache.tiles.ComponentAttribute getAttribute(java.lang.String beanName, int scope, javax.servlet.jsp.PageContext pageContext)
          Get object from requested context.
 java.util.Iterator<java.lang.String> getAttributeNames()
          Get names of all attributes.
static org.apache.tiles.ComponentContext getContext(TilesRequestContext tilesContext)
          Get component context from request.
static java.util.Stack<org.apache.tiles.ComponentContext> getContextStack(TilesRequestContext tilesContext)
          Returns the context stack.
static org.apache.tiles.ComponentContext popContext(TilesRequestContext tilesContext)
          Pops a context object out of the stack
static void pushContext(org.apache.tiles.ComponentContext context, TilesRequestContext tilesContext)
          Pushes a context object in the stack.
 void putAttribute(java.lang.String name, org.apache.tiles.ComponentAttribute value)
          Put a new attribute to context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicComponentContext

public BasicComponentContext()
Constructor.


BasicComponentContext

public BasicComponentContext(java.util.Map<java.lang.String,org.apache.tiles.ComponentAttribute> attributes)
Constructor. Create a context and set specified attributes.

Parameters:
attributes - Attributes to initialize context.

BasicComponentContext

public BasicComponentContext(org.apache.tiles.ComponentContext context)
Method Detail

addAll

public void addAll(java.util.Map<java.lang.String,org.apache.tiles.ComponentAttribute> newAttributes)
Add all attributes to this context. Copies all of the mappings from the specified attribute map to this context. New attribute mappings will replace any mappings that this context had for any of the keys currently in the specified attribute map.

Specified by:
addAll in interface org.apache.tiles.ComponentContext
Parameters:
newAttributes - Attributes to add.

addMissing

public void addMissing(java.util.Map<java.lang.String,org.apache.tiles.ComponentAttribute> defaultAttributes)
Add all missing attributes to this context. Copies all of the mappings from the specified attributes map to this context. New attribute mappings will be added only if they don't already exist in this context.

Specified by:
addMissing in interface org.apache.tiles.ComponentContext
Parameters:
defaultAttributes - Attributes to add.

getAttribute

public org.apache.tiles.ComponentAttribute getAttribute(java.lang.String name)
Get an attribute from context.

Specified by:
getAttribute in interface org.apache.tiles.ComponentContext
Parameters:
name - Name of the attribute.
Returns:
<{ComponentAttribute}>

getAttributeNames

public java.util.Iterator<java.lang.String> getAttributeNames()
Get names of all attributes.

Specified by:
getAttributeNames in interface org.apache.tiles.ComponentContext
Returns:
<{ComponentAttribute}>

putAttribute

public void putAttribute(java.lang.String name,
                         org.apache.tiles.ComponentAttribute value)
Put a new attribute to context.

Specified by:
putAttribute in interface org.apache.tiles.ComponentContext
Parameters:
name - Name of the attribute.
value - Value of the attribute.

findAttribute

public org.apache.tiles.ComponentAttribute findAttribute(java.lang.String beanName,
                                                         javax.servlet.jsp.PageContext pageContext)
Find object in one of the contexts. Order : component then pageContext.findAttribute()

Specified by:
findAttribute in interface org.apache.tiles.ComponentContext
Parameters:
beanName - Name of the bean to find.
pageContext - Page context.
Returns:
Requested bean or null if not found.

getAttribute

public org.apache.tiles.ComponentAttribute getAttribute(java.lang.String beanName,
                                                        int scope,
                                                        javax.servlet.jsp.PageContext pageContext)
Get object from requested context. Context can be 'component'.

Specified by:
getAttribute in interface org.apache.tiles.ComponentContext
Parameters:
beanName - Name of the bean to find.
scope - Search scope (see PageContext).
pageContext - Page context.
Returns:
requested bean or null if not found.

getContext

public static org.apache.tiles.ComponentContext getContext(TilesRequestContext tilesContext)
Get component context from request.

Parameters:
tilesContext - current Tiles application context.
Returns:
BasicComponentContext or null if context is not found or an jspException is present in the request.

getContextStack

public static java.util.Stack<org.apache.tiles.ComponentContext> getContextStack(TilesRequestContext tilesContext)
Returns the context stack.

Parameters:
tilesContext - The Tiles context object to use.
Returns:
The needed stack of contexts.

pushContext

public static void pushContext(org.apache.tiles.ComponentContext context,
                               TilesRequestContext tilesContext)
Pushes a context object in the stack.

Parameters:
context - The context to push.
tilesContext - The Tiles context object to use.

popContext

public static org.apache.tiles.ComponentContext popContext(TilesRequestContext tilesContext)
Pops a context object out of the stack

Parameters:
tilesContext - The Tiles context object to use.
Returns:
The popped context object.

clear

public void clear()
Specified by:
clear in interface org.apache.tiles.ComponentContext