|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.hivemind.impl.BaseLocatable
org.apache.tapestry.AbstractComponent
Abstract base class implementing the IComponent
interface.
Constructor Summary | |
AbstractComponent()
|
Method Summary | |
void |
addAsset(java.lang.String name,
IAsset asset)
Adds an asset to the component. |
void |
addBody(IRender element)
Adds an element (which may be static text or a component) as a body element of this component. |
void |
addComponent(IComponent component)
Adds a component to a container. |
protected void |
checkActiveLock()
|
protected void |
cleanupAfterRender(IRequestCycle cycle)
Invoked by render(IMarkupWriter, IRequestCycle) after the component renders. |
void |
enterActiveState()
Invoked after finishLoad(IRequestCycle, IPageLoader, IComponentSpecification) to
switch the component from its initial construction state into its active state. |
protected void |
finishLoad()
Invoked, as a convienience, from finishLoad(IRequestCycle, IPageLoader, IComponentSpecification) . |
void |
finishLoad(IRequestCycle cycle,
IPageLoader loader,
IComponentSpecification specification)
Invokes finishLoad() . |
java.lang.String |
format(java.lang.String key,
java.lang.Object argument)
Deprecated. To be removed in 4.1. Use getMessages() instead. |
java.lang.String |
format(java.lang.String key,
java.lang.Object[] arguments)
Deprecated. To be removed in 4.1. Use getMessages() instead. |
java.lang.String |
format(java.lang.String key,
java.lang.Object argument1,
java.lang.Object argument2)
Deprecated. To be removed in 4.1. Use getMessages() instead. |
java.lang.String |
format(java.lang.String key,
java.lang.Object argument1,
java.lang.Object argument2,
java.lang.Object argument3)
Deprecated. To be removed in 4.1. Use getMessages() instead. |
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 the IBeanProvider for this component. |
IBinding |
getBinding(java.lang.String name)
Returns the named binding, or null if it doesn't exist. |
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 an unmodifiable Map of all bindings for this component. |
IRender[] |
getBody()
Returns the body of the component, the element (which may be static HTML or components) that the component immediately wraps. |
int |
getBodyCount()
Returns the active number of elements in the the body, which may be zero. |
IComponent |
getComponent(java.lang.String id)
Retrieves an contained component by its id. |
java.util.Map |
getComponents()
Returns an unmodifiable Map of components, keyed on component id. |
IContainedComponent |
getContainedComponent()
Returns the IContainedComponent . |
IComponent |
getContainer()
Returns the component which embeds the receiver. |
java.lang.String |
getExtendedId()
Returns the name of the page, a slash, and this component's id path. |
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 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. |
IComponentSpecification |
getSpecification()
Returns the specification which defines the component. |
protected boolean |
isInActiveState()
Returns true if the component has been transitioned into its active state by invoking enterActiveState() |
boolean |
isParameterBound(java.lang.String parameterName)
Returns true if the specified parameter is bound. |
boolean |
isRendering()
Returns true if the component is currently rendering. |
void |
pageEndRender(PageEvent event)
Empty implementation of PageEndRenderListener.pageEndRender(PageEvent) . |
protected void |
prepareForRender(IRequestCycle cycle)
Invoked by render(IMarkupWriter, IRequestCycle) to prepare the component to render. |
void |
render(IMarkupWriter writer,
IRequestCycle cycle)
The main method used to render the component. |
void |
renderBody(IMarkupWriter writer,
IRequestCycle cycle)
Renders all elements wrapped by the receiver. |
protected abstract void |
renderComponent(IMarkupWriter writer,
IRequestCycle cycle)
Invoked by render(IMarkupWriter, IRequestCycle) to actually render the component
(with any parameter values already set). |
protected void |
renderInformalParameters(IMarkupWriter writer,
IRequestCycle cycle)
Converts informal parameters into additional attributes on the curently open tag. |
void |
setBinding(java.lang.String name,
IBinding binding)
Adds the binding with the given name, replacing any existing binding with that name. |
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. |
java.lang.String |
toString()
|
Methods inherited from class org.apache.hivemind.impl.BaseLocatable |
getLocation, setLocation |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.apache.hivemind.LocationHolder |
setLocation |
Methods inherited from interface org.apache.hivemind.Locatable |
getLocation |
Constructor Detail |
public AbstractComponent()
Method Detail |
public void addAsset(java.lang.String name, IAsset asset)
IComponent
addAsset
in interface IComponent
public void addComponent(IComponent component)
IComponent
addComponent
in interface IComponent
IPageLoader
public void addBody(IRender element)
renderBody(IMarkupWriter, IRequestCycle)
.
addBody
in interface IComponent
public void finishLoad(IRequestCycle cycle, IPageLoader loader, IComponentSpecification specification)
finishLoad()
. Subclasses may overide as needed, but must invoke this
implementation. BaseComponent
loads its HTML template.
finishLoad
in interface IComponent
protected void renderInformalParameters(IMarkupWriter writer, IRequestCycle cycle)
Invoked from subclasses to allow additional attributes to be specified within a tag (this
works best when there is a one-to-one corespondence between an IComponent
and a HTML
element.
Iterates through the bindings for this component. Filters out bindings for formal parameters.
For each acceptible key, the value is extracted using IBinding.getObject()
. If the
value is null, no attribute is written.
If the value is an instance of IAsset
, then IAsset.buildURL()
is invoked to convert the asset to a URL.
Finally, IMarkupWriter.attribute(String,String)
is invoked with the value (or the
URL).
The most common use for informal parameters is to support the HTML class attribute (for use with cascading style sheets) and to specify JavaScript event handlers.
Components are only required to generate attributes on the result phase; this can be skipped during the rewind phase.
public IBinding getBinding(java.lang.String name)
In Tapestry 3.0, it was possible to force a binding to be stored in a component property by
defining a concrete or abstract property named "nameBinding" of type IBinding
. This
has been removed in release 4.0 and bindings are always stored inside a Map of the component.
getBinding
in interface IComponent
setBinding(String,IBinding)
public boolean isParameterBound(java.lang.String parameterName)
public IComponent getComponent(java.lang.String id)
IComponent
getComponent
in interface IComponent
public IComponent getContainer()
IComponent
A page returns null.
getContainer
in interface IComponent
public void setContainer(IComponent value)
IComponent
ApplicationRuntimeException
.
setContainer
in interface IComponent
public java.lang.String getExtendedId()
getExtendedId
in interface IComponent
getIdPath()
public java.lang.String getId()
IComponent
An id will be unique within the component which contains this component.
A page
will always return null.
getId
in interface IComponent
public void setId(java.lang.String value)
IComponent
ApplicationRuntimeException
.
setId
in interface IComponent
public java.lang.String getIdPath()
IComponent
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.
getIdPath
in interface IComponent
IComponent.getId()
public IPage getPage()
IComponent
getPage
in interface IComponent
public void setPage(IPage value)
IComponent
ApplicationRuntimeException
.
setPage
in interface IComponent
public void renderBody(IMarkupWriter writer, IRequestCycle cycle)
renderBody
in interface IComponent
public void setBinding(java.lang.String name, IBinding binding)
setBinding
in interface IComponent
getBinding(String)
public java.lang.String toString()
public java.util.Map getComponents()
Map
of components, keyed on component id. Never returns null,
but may return an empty map. The returned map is immutable.
getComponents
in interface IComponent
public java.util.Map getAssets()
IComponent
The return value is unmodifiable.
getAssets
in interface IComponent
public IAsset getAsset(java.lang.String name)
IComponent
getAsset
in interface IComponent
public java.util.Collection getBindingNames()
IComponent
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.
getBindingNames
in interface IComponent
public java.util.Map getBindings()
Map
of all bindings for this component.
getBindings
in interface IComponent
public ListenerMap getListeners()
ListenerMap
for the component. A ListenerMap contains a number of
synthetic read-only properties that implement the IActionListener
interface, but in
fact, cause public instance methods to be invoked.
getListeners
in interface IComponent
public IBeanProvider getBeans()
IBeanProvider
for this component. This is lazily created the first time
it is needed.
getBeans
in interface IComponent
protected void finishLoad()
finishLoad(IRequestCycle, IPageLoader, IComponentSpecification)
. This implemenation
does nothing. Subclasses may override without invoking this implementation.
public final void render(IMarkupWriter writer, IRequestCycle cycle)
prepareForRender(IRequestCycle)
, then
renderComponent(IMarkupWriter, IRequestCycle)
.
cleanupAfterRender(IRequestCycle)
is invoked in a finally
block.
Subclasses should not override this method; instead they will implement
renderComponent(IMarkupWriter, IRequestCycle)
.
render
in interface IRender
protected void prepareForRender(IRequestCycle cycle)
render(IMarkupWriter, IRequestCycle)
to prepare the component to render.
This implementation sets JavaBeans properties from matching bound parameters. This
implementation does nothing.
protected abstract void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
render(IMarkupWriter, IRequestCycle)
to actually render the component
(with any parameter values already set). This is the method that subclasses must implement.
protected void cleanupAfterRender(IRequestCycle cycle)
render(IMarkupWriter, IRequestCycle)
after the component renders. This
implementation does nothing.
public INamespace getNamespace()
IComponent
INamespace
in which the component was defined (as an alias).
getNamespace
in interface IComponent
public void setNamespace(INamespace namespace)
IComponent
INamespace
for the component. The namespace should only be set once.
setNamespace
in interface IComponent
public IRender[] getBody()
getBodyCount()
public int getBodyCount()
getBody()
public void pageEndRender(PageEvent event)
PageEndRenderListener.pageEndRender(PageEvent)
. This allows
classes to implement PageRenderListener
and only implement
the PageBeginRenderListener.pageBeginRender(PageEvent)
method.
public void setProperty(java.lang.String propertyName, java.lang.Object value)
setProperty
in interface IComponent
propertyName
- the property namevalue
- the provided valueIComponent
public java.lang.Object getProperty(java.lang.String propertyName)
getProperty
in interface IComponent
propertyName
- the property name
IComponent
public final boolean isRendering()
IComponent
isRendering
in interface IComponent
protected final boolean isInActiveState()
enterActiveState()
public final void enterActiveState()
IComponent
IComponent.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
IComponent.finishLoad(IRequestCycle, IPageLoader, IComponentSpecification)
.
enterActiveState
in interface IComponent
protected final void checkActiveLock()
public org.apache.hivemind.Messages getMessages()
IComponent
getMessages
in interface IComponent
public IComponentSpecification getSpecification()
IComponent
getSpecification
in interface IComponent
public java.lang.String getMessage(java.lang.String key)
getMessages()
instead.
getMessage
in interface IComponent
key
- the key used to locate the message
public java.lang.String format(java.lang.String key, java.lang.Object[] arguments)
getMessages()
instead.
Messages.format(java.lang.String, java.lang.Object[])
.
key
- the key used to obtain a localized patternarguments
- passed to the formatterpublic java.lang.String format(java.lang.String key, java.lang.Object argument)
getMessages()
instead.
IMessages#format(String, Locale, Object)
public java.lang.String format(java.lang.String key, java.lang.Object argument1, java.lang.Object argument2)
getMessages()
instead.
Messages.format(String, Object, Object)
.
public java.lang.String format(java.lang.String key, java.lang.Object argument1, java.lang.Object argument2, java.lang.Object argument3)
getMessages()
instead.
Messages.format(String, Object, Object, Object)
.
public final IContainedComponent getContainedComponent()
IComponent
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.
getContainedComponent
in interface IComponent
public final void setContainedComponent(IContainedComponent containedComponent)
IComponent
IComponent.getContainedComponent()
property; this may only be done once.
setContainedComponent
in interface IComponent
containedComponent
- may not be null
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |