public interface IComponent extends IRender, org.apache.hivemind.LocationHolder
Components are created dynamically from thier class names (part of the
IComponentSpecification
).
Modifier and Type | Method and Description |
---|---|
void |
addAsset(java.lang.String name,
IAsset asset)
Adds an asset to the component.
|
void |
addBody(IRender element)
Adds a new renderable element to the receiver's body.
|
void |
addComponent(IComponent component)
Adds a component to a container.
|
void |
enterActiveState()
Invoked after
finishLoad(IRequestCycle, IPageLoader, IComponentSpecification) to
switch the component from its initial construction state into its active state. |
void |
finishLoad(IRequestCycle cycle,
IPageLoader loader,
IComponentSpecification specification)
Allows a component to finish any setup after it has been constructed.
|
IAsset |
getAsset(java.lang.String name)
Returns the named asset, or null if not found.
|
java.util.Map |
getAssets()
Returns the asset map for the component, which may be empty but will not be null.
|
IBeanProvider |
getBeans()
Returns a
IBeanProvider from which managed beans can be obtained. |
IBinding |
getBinding(java.lang.String name)
Returns the binding with the given name or null if not found.
|
java.util.Collection |
getBindingNames()
Returns a
Collection of the names of all bindings (which includes bindings for both
formal and informal parameters). |
java.util.Map |
getBindings()
Returns a
Map of the bindings for this component; this includes
informal parameters as well as formal bindings. |
IComponent |
getComponent(java.lang.String id)
Retrieves an contained component by its id.
|
java.util.Map |
getComponents()
Returns the contained components as an unmodifiable
Map . |
IContainedComponent |
getContainedComponent()
Returns the
IContainedComponent . |
IComponent |
getContainer()
Returns the component which embeds the receiver.
|
java.lang.String |
getExtendedId()
Returns a string identifying the name of the page and the id path of the reciever within the
page (seperated by a slash).
|
java.lang.String |
getId()
Returns the simple id of the component, as defined in its specification.
|
java.lang.String |
getIdPath()
Returns the qualified id of the component.
|
ListenerMap |
getListeners()
Returns a
ListenerMap for the component. |
java.lang.String |
getMessage(java.lang.String key)
Deprecated.
To be removed in release 4.1. Use
getMessages() instead. |
org.apache.hivemind.Messages |
getMessages()
Returns component strings for the component.
|
INamespace |
getNamespace()
Returns the
INamespace in which the component was defined (as an alias). |
IPage |
getPage()
Returns the page which ultimately contains the receiver.
|
java.lang.Object |
getProperty(java.lang.String propertyName)
Deprecated.
To be removed in 4.1. Use
PropertyUtils.read(java.lang.Object, java.lang.String)
instead |
IComponentSpecification |
getSpecification()
Returns the specification which defines the component.
|
boolean |
isRendering()
Returns true if the component is currently rendering.
|
void |
renderBody(IMarkupWriter writer,
IRequestCycle cycle)
Invoked to make the receiver render its body (the elements and components its tag wraps
around, on its container's template).
|
void |
setBinding(java.lang.String name,
IBinding binding)
Adds a binding to a container.
|
void |
setContainedComponent(IContainedComponent containedComponent)
Sets the
getContainedComponent() property; this may only be done once. |
void |
setContainer(IComponent value)
Sets the container of the component.
|
void |
setId(java.lang.String value)
Sets the id of the component.
|
void |
setNamespace(INamespace namespace)
Sets the
INamespace for the component. |
void |
setPage(IPage value)
Sets the page which ultimiately contains the component.
|
void |
setProperty(java.lang.String propertyName,
java.lang.Object value)
Deprecated.
To be removed in 4.1. Use
{@link org.apache.hivemind.util.PropertyUtils#read(java.lang.Object, java.lang.String) instead.
|
void addAsset(java.lang.String name, IAsset asset)
void addComponent(IComponent component)
IPageLoader
void addBody(IRender element)
The method renderBody(IMarkupWriter, IRequestCycle)
is used to render these
elements.
java.util.Map getAssets()
The return value is unmodifiable.
IBinding getBinding(java.lang.String name)
Bindings are added to a component using setBinding(String,IBinding)
.
java.util.Collection getBindingNames()
Collection
of the names of all bindings (which includes bindings for both
formal and informal parameters).
The return value is unmodifiable. It will be null for a page
, or may simply be
empty for a component with no bindings.
java.util.Map getBindings()
Map
of the bindings
for this component; this includes
informal parameters as well as formal bindings.IComponent getComponent(java.lang.String id)
ApplicationRuntimeException
- runtime exception thrown if the named component does not exist.IComponent getContainer()
A page returns null.
void setContainer(IComponent value)
ApplicationRuntimeException
.java.lang.String getExtendedId()
getIdPath()
java.lang.String getId()
An id will be unique within the component which contains this component.
A page
will always return null.
void setId(java.lang.String value)
ApplicationRuntimeException
.java.lang.String getIdPath()
page
to this component, showing how components contain each other.
A page
will always return null. A component contained on a page returns its
simple id. Other components return their container's id path followed by a period and their
own name.
getId()
IPage getPage()
void setPage(IPage value)
ApplicationRuntimeException
.IComponentSpecification getSpecification()
void renderBody(IMarkupWriter writer, IRequestCycle cycle)
RenderBody
component may operate.void setBinding(java.lang.String name, IBinding binding)
IPageLoader
java.util.Map getComponents()
Map
. This allows peer components
to work together without directly involving their container ... the classic example is to
have an Insert
work with an enclosing
Foreach
.
This is late addition to Tapestry, because it also opens the door to abuse, since it is quite possible to break the "black box" aspect of a component by interacting directly with components it embeds. This creates ugly interelationships between components that should be seperated.
void finishLoad(IRequestCycle cycle, IPageLoader loader, IComponentSpecification specification)
The exact timing is not specified, but any components contained by the receiving component will also have been constructed before this method is invoked.
As of release 1.0.6, this method is invoked before bindings are set. This should not affect anything, as bindings should only be used during renderring.
Release 2.2 added the cycle parameter which is, regretfully, not backwards compatible.
org.apache.hivemind.Messages getMessages()
INamespace getNamespace()
INamespace
in which the component was defined (as an alias).void setNamespace(INamespace namespace)
INamespace
for the component. The namespace should only be set once.void setProperty(java.lang.String propertyName, java.lang.Object value)
propertyName
- the property namevalue
- the provided valuejava.lang.Object getProperty(java.lang.String propertyName)
PropertyUtils.read(java.lang.Object, java.lang.String)
insteadpropertyName
- the property nameboolean isRendering()
void enterActiveState()
finishLoad(IRequestCycle, IPageLoader, IComponentSpecification)
to
switch the component from its initial construction state into its active state. The
difference concerns parameters, whose defaults values may be set from inside
finishLoad(IRequestCycle, IPageLoader, IComponentSpecification)
.IBeanProvider getBeans()
IBeanProvider
from which managed beans can be obtained.ListenerMap getListeners()
ListenerMap
for the component. The map contains a number of synthetic
read-only properties that implement the IActionListener
interface, but in fact, cause
public instance methods to be invoked (via reflection).java.lang.String getMessage(java.lang.String key)
getMessages()
instead.key
- the key used to locate the messageIContainedComponent getContainedComponent()
IContainedComponent
. This will be null for
pages. This property is set when a component is constructed, and links the component instance
to the reference in the containing page or component's template or specification. This is
useful to allow a component to know its type or the meta-data associated with the component.void setContainedComponent(IContainedComponent containedComponent)
getContainedComponent()
property; this may only be done once.containedComponent
- may not be null