|
||||||||||
| 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 IComponentinterface.
| Field Summary | |
|---|---|
protected IRender[] |
_body
An aray of elements in the body of this component. |
protected int |
_bodyCount
The number of IRenderobjects 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 IBeanProviderfor this component. |
IBinding |
getBinding(String name)
Returns the named binding, or null if it doesn't exist. |
Collection |
getBindingNames()
Returns a Collectionof the names of all bindings (which includes bindings for both
formal and informal parameters). |
Map |
getBindings()
Returns an unmodifiable Mapof 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 Mapof 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 INamespacein 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 INamespacefor 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
IRenderobjects 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 IComponentname - 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 IComponentcomponent - The component to add.IPageLoaderpublic void addBody(IRender element)
renderBody(IMarkupWriter, IRequestCycle).
addBody in interface IComponentpublic IRender[] getContainedRenderers()
ComponentIRender elements contained by this component. Ie whatever
has been added via IComponent.addBody(IRender).
getContainedRenderers in interface Componentpublic IRender[] getInnerRenderers()
ComponentBaseComponent. 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 Componentpublic boolean hasEvents()
Component
hasEvents in interface Componentpublic void setHasEvents(boolean hasEvents)
Component
setHasEvents in interface ComponenthasEvents - 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 IComponentand 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 IComponentsetBinding(String,IBinding)public boolean isParameterBound(String parameterName)
public IComponent getComponent(String id)
IComponent
getComponent in interface IComponentpublic IComponent getContainer()
IComponentA page returns null.
getContainer in interface IComponentpublic void setContainer(IComponent value)
IComponentApplicationRuntimeException.
setContainer in interface IComponentpublic String getExtendedId()
getExtendedId in interface IComponentgetIdPath()public String getSpecifiedId()
IComponentIComponent.getId() value OR the value of any binding
named id - if one exists. Higher precedence is given to bound id values.
getSpecifiedId in interface IComponentpublic String getId()
IComponentAn id will be unique within the component which contains this component.
A pagewill always return null.
getId in interface IComponentpublic void setId(String value)
IComponentApplicationRuntimeException.
setId in interface IComponentpublic String getIdPath()
IComponentpage
to this component, showing how components contain each other.
A pagewill 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 IComponentIComponent.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 IComponentpublic abstract void setClientId(String id)
IComponent
setClientId in interface IComponentid - The client id to set.public String peekClientId()
IRequestCycle.peekUniqueId(String).
peekClientId in interface IComponentprotected void generateClientId()
protected String getBoundId()
public String getTemplateTagName()
IComponentExample:
<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 IComponentpublic 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 IComponenttag - The tag name to set.public IPage getPage()
IComponent
getPage in interface IComponentpublic void setPage(IPage value)
IComponentApplicationRuntimeException.
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 IComponentgetBinding(String)public String toString()
toString in class Objectpublic Map getComponents()
Mapof components, keyed on component id. Never returns null,
but may return an empty map. The returned map is immutable.
getComponents in interface IComponentpublic Map getAssets()
IComponentThe return value is unmodifiable.
getAssets in interface IComponentpublic IAsset getAsset(String name)
IComponent
getAsset in interface IComponentpublic Collection getBindingNames()
IComponentCollectionof 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 IComponentpublic Map getBindings()
Mapof all bindings for this component.
getBindings in interface IComponentpublic ListenerMap getListeners()
ListenerMap for the component. A ListenerMap contains a number of
synthetic read-only properties that implement the IActionListenerinterface, but in
fact, cause public instance methods to be invoked.
getListeners in interface IComponentpublic IBeanProvider getBeans()
IBeanProviderfor this component. This is lazily created the first time
it is needed.
getBeans in interface IComponentprotected 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 IRenderprotected 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()
IComponentINamespacein which the component was defined (as an alias).
getNamespace in interface IComponentpublic void setNamespace(INamespace namespace)
IComponentINamespacefor the component. The namespace should only be set once.
setNamespace in interface IComponentpublic IRender[] getBody()
getBodyCount()public int getBodyCount()
getBody()public void pageEndRender(PageEvent event)
PageEndRenderListener.pageEndRender(PageEvent). This allows
classes to implement PageRenderListenerand only implement
the PageBeginRenderListener.pageBeginRender(PageEvent)method.
public final boolean isRendering()
IComponent
isRendering in interface IComponentprotected final boolean isInActiveState()
enterActiveState().
public final void enterActiveState()
IComponentIComponent.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 IComponentprotected final void checkActiveLock()
public org.apache.hivemind.Messages getMessages()
IComponent
getMessages in interface IComponentpublic IComponentSpecification getSpecification()
IComponent
getSpecification in interface IComponentpublic final IContainedComponent getContainedComponent()
IComponentIContainedComponent. 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 IComponentpublic final void setContainedComponent(IContainedComponent containedComponent)
IComponentIComponent.getContainedComponent() property; this may only be done once.
setContainedComponent in interface IComponentcontainedComponent - may not be nullpublic IComponentEventInvoker getEventInvoker()
getEventInvoker in interface IComponent
public void triggerEvent(IRequestCycle cycle,
BrowserEvent event)
triggerEvent in interface IDirectEventpublic ComponentRenderWorker getRenderWorker()
public boolean isStateful()
HttpSession is active, then a
StaleSessionException is
thrown by the service.
isStateful in interface IDirectEventpublic int hashCode()
hashCode in class Objectpublic boolean equals(Object obj)
equals in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||