|
||||||||||
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
public abstract class AbstractComponent
Abstract base class implementing the IComponent
interface.
Field Summary | |
---|---|
protected IRender[] |
_body
An aray of elements in the body of this component. |
protected int |
_bodyCount
The number of IRender objects in the body of this component. |
Constructor Summary | |
---|---|
AbstractComponent()
|
Method Summary | |
---|---|
void |
addAsset(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 IComponent.finishLoad(IRequestCycle, IPageLoader, IComponentSpecification) to
switch the component from its initial construction state into its active state. |
boolean |
equals(Object obj)
|
protected void |
finishLoad()
Invoked, as a convienience, from finishLoad(IRequestCycle, IPageLoader, IComponentSpecification) . |
void |
finishLoad(IRequestCycle cycle,
IPageLoader loader,
IComponentSpecification specification)
Invokes finishLoad() . |
protected void |
generateClientId()
|
IAsset |
getAsset(String name)
Returns the named asset, or null if not found. |
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(String name)
Returns the named binding, or null if it doesn't exist. |
Collection |
getBindingNames()
Returns a Collection of the names of all bindings (which includes bindings for both
formal and informal parameters). |
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. |
protected String |
getBoundId()
|
abstract String |
getClientId()
Returns the component's client-side element id. |
IComponent |
getComponent(String id)
Retrieves an contained component by its id. |
Map |
getComponents()
Returns an unmodifiable Map of components, keyed on component id. |
IContainedComponent |
getContainedComponent()
Returns the IContainedComponent . |
IRender[] |
getContainedRenderers()
Returns the list of of IRender elements contained by this component. |
IComponent |
getContainer()
Returns the component which embeds the receiver. |
IComponentEventInvoker |
getEventInvoker()
Returns the event connection manager services that handles creating/accepting browser events associated with various properties of components. |
String |
getExtendedId()
Returns the name of the page, a slash, and this component's id path. |
String |
getId()
Returns the simple id of the component, as defined in its specification. |
String |
getIdPath()
Returns the qualified id of the component. |
IRender[] |
getInnerRenderers()
In some rare cases a component has both outer and inner renderers - such as with BaseComponent . |
ListenerMap |
getListeners()
Returns a ListenerMap for the component. |
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. |
ComponentRenderWorker |
getRenderWorker()
|
IComponentSpecification |
getSpecification()
Returns the specification which defines the component. |
String |
getSpecifiedId()
Returns either the normal IComponent.getId() value OR the value of any binding
named id - if one exists. |
String |
getTemplateTagName()
Though most component implementations ignore the specific html tag used to reference a component, this value may be used for those components that do wish to use the same tag that was provided when rendering a component. |
boolean |
hasEvents()
Checks if this component has been targeted / connected to for client side event listening via @EventListener. |
int |
hashCode()
|
protected boolean |
isInActiveState()
Returns true if the component has been transitioned into its active state by invoking enterActiveState() . |
boolean |
isParameterBound(String parameterName)
Returns true if the specified parameter is bound. |
boolean |
isRendering()
Returns true if the component is currently rendering. |
boolean |
isStateful()
Invoked by the event service to query the component as to whether it is stateful. |
void |
pageEndRender(PageEvent event)
Empty implementation of PageEndRenderListener.pageEndRender(PageEvent) . |
String |
peekClientId()
Used internally to "peek" at what the next generated client id will be for this component when it renders. |
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 |
renderIdAttribute(IMarkupWriter writer,
IRequestCycle cycle)
Renders the (unique) id attribute for this component. |
protected void |
renderInformalParameters(IMarkupWriter writer,
IRequestCycle cycle)
Converts informal parameters into additional attributes on the curently open tag. |
void |
setBinding(String name,
IBinding binding)
Adds the binding with the given name, replacing any existing binding with that name. |
abstract void |
setClientId(String id)
Sets the client ID. |
void |
setContainedComponent(IContainedComponent containedComponent)
Sets the IComponent.getContainedComponent() property; this may only be done once. |
void |
setContainer(IComponent value)
Sets the container of the component. |
void |
setHasEvents(boolean hasEvents)
Sets whether or not this component has events. |
void |
setId(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 |
setTemplateTagName(String tag)
Sets the template tag name used to reference this component. |
String |
toString()
|
void |
triggerEvent(IRequestCycle cycle,
BrowserEvent event)
Invoked by the event service to have the component peform the appropriate action. |
Methods inherited from class org.apache.hivemind.impl.BaseLocatable |
---|
getLocation, setLocation |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.apache.hivemind.LocationHolder |
---|
setLocation |
Methods inherited from interface org.apache.hivemind.Locatable |
---|
getLocation |
Field Detail |
---|
protected int _bodyCount
IRender
objects in the body of this component.
protected IRender[] _body
Constructor Detail |
---|
public AbstractComponent()
Method Detail |
---|
public void addAsset(String name, IAsset asset)
IComponent
addAsset
in interface IComponent
name
- The lookup name the asset will be bound to and referenacable as.asset
- The asset to add.public void addComponent(IComponent component)
IComponent
addComponent
in interface IComponent
component
- The component to add.IPageLoader
public void addBody(IRender element)
renderBody(IMarkupWriter, IRequestCycle)
.
addBody
in interface IComponent
public IRender[] getContainedRenderers()
Component
IRender
elements contained by this component. Ie whatever
has been added via IComponent.addBody(IRender)
.
getContainedRenderers
in interface Component
public IRender[] getInnerRenderers()
Component
BaseComponent
. This
value should return the normal inner renderers most components do in those instances while the other
Component.getContainedRenderers()
should return the outer renderers.
getInnerRenderers
in interface Component
public boolean hasEvents()
Component
hasEvents
in interface Component
public void setHasEvents(boolean hasEvents)
Component
setHasEvents
in interface Component
hasEvents
- Whether or not this component has connected events.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.
protected void renderIdAttribute(IMarkupWriter writer, IRequestCycle cycle)
writer
- The writer to render attribute in.cycle
- The current request.public IBinding getBinding(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(String parameterName)
public IComponent getComponent(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 String getExtendedId()
getExtendedId
in interface IComponent
getIdPath()
public String getSpecifiedId()
IComponent
IComponent.getId()
value OR the value of any binding
named id
- if one exists. Higher precedence is given to bound id values.
getSpecifiedId
in interface IComponent
public 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(String value)
IComponent
ApplicationRuntimeException
.
setId
in interface IComponent
public 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 abstract String getClientId()
IFormComponent
only binding but now applies to all components. The method
should check to see if any id parameter/property has been set already and use that
above all others, falling back to IComponent.getId()
if nothing else is found.
getClientId
in interface IComponent
public abstract void setClientId(String id)
IComponent
setClientId
in interface IComponent
id
- The client id to set.public String peekClientId()
IRequestCycle.peekUniqueId(String)
.
peekClientId
in interface IComponent
protected void generateClientId()
protected String getBoundId()
public String getTemplateTagName()
IComponent
Example:
<fieldset jwcid="@If" condition="true" > <input type="text" /> </fieldset>
In the example above, the value of the template tag would be "fieldset" for the If component.
getTemplateTagName
in interface IComponent
public void setTemplateTagName(String tag)
Set by the component template loader automatically, people shouldn't normally have any reason to try setting this.
setTemplateTagName
in interface IComponent
tag
- The tag name to set.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(String name, IBinding binding)
setBinding
in interface IComponent
getBinding(String)
public String toString()
toString
in class Object
public 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 Map getAssets()
IComponent
The return value is unmodifiable.
getAssets
in interface IComponent
public IAsset getAsset(String name)
IComponent
getAsset
in interface IComponent
public 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 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. The default
implementation of this method is empty.
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.
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 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 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 nullpublic IComponentEventInvoker getEventInvoker()
getEventInvoker
in interface IComponent
public void triggerEvent(IRequestCycle cycle, BrowserEvent event)
triggerEvent
in interface IDirectEvent
public ComponentRenderWorker getRenderWorker()
public boolean isStateful()
HttpSession
is active, then a
StaleSessionException
is
thrown by the service.
isStateful
in interface IDirectEvent
public int hashCode()
hashCode
in class Object
public boolean equals(Object obj)
equals
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |