org.apache.struts.tiles

Class ComponentContext

public class ComponentContext extends Object implements Serializable

Component context.
Field Summary
Mapattributes
Component attributes.
Constructor Summary
ComponentContext()
Constructor.
ComponentContext(Map attributes)
Constructor.
Method Summary
voidaddAll(Map newAttributes)
Add all attributes to this context.
voidaddMissing(Map defaultAttributes)
Add all missing attributes to this context.
ObjectfindAttribute(String beanName, PageContext pageContext)
Find object in one of the contexts.
ObjectgetAttribute(String name)
Get an attribute from context.
ObjectgetAttribute(String beanName, int scope, PageContext pageContext)
Get object from requested context.
IteratorgetAttributeNames()
Get names of all attributes.
static ComponentContextgetContext(ServletRequest request)
Get component context from request.
voidputAttribute(String name, Object value)
Put a new attribute to context.
static voidsetContext(ComponentContext context, ServletRequest request)
Store component context into request.

Field Detail

attributes

private Map attributes
Component attributes.

Constructor Detail

ComponentContext

public ComponentContext()
Constructor.

ComponentContext

public ComponentContext(Map attributes)
Constructor. Create a context and set specified attributes.

Parameters: attributes Attributes to initialize context.

Method Detail

addAll

public void addAll(Map 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.

Parameters: newAttributes Attributes to add.

addMissing

public void addMissing(Map 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.

Parameters: defaultAttributes Attributes to add.

findAttribute

public Object findAttribute(String beanName, PageContext pageContext)
Find object in one of the contexts. Order : component then pageContext.findAttribute()

Parameters: beanName Name of the bean to find. pageContext Page context.

Returns: Requested bean or null if not found.

getAttribute

public Object getAttribute(String name)
Get an attribute from context.

Parameters: name Name of the attribute.

Returns: <{Object}>

getAttribute

public Object getAttribute(String beanName, int scope, PageContext pageContext)
Get object from requested context. Context can be 'component'.

Parameters: beanName Name of the bean to find. scope Search scope (see {@link PageContext}). pageContext Page context.

Returns: requested bean or null if not found.

getAttributeNames

public Iterator getAttributeNames()
Get names of all attributes.

Returns: <{Object}>

getContext

public static ComponentContext getContext(ServletRequest request)
Get component context from request.

Parameters: request ServletRequest.

Returns: ComponentContext or null if context is not found or an jspException is present in the request.

putAttribute

public void putAttribute(String name, Object value)
Put a new attribute to context.

Parameters: name Name of the attribute. value Value of the attribute.

setContext

public static void setContext(ComponentContext context, ServletRequest request)
Store component context into request.

Parameters: context ComponentContext to store. request Request to store ComponentContext.

Copyright © 2000-2008 - The Apache Software Foundation