|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.apache.tapestry.spec.BaseLocatable
org.apache.tapestry.AbstractComponent
public abstract class AbstractComponent
Abstract base class implementing the IComponent interface.
| 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 |
cleanupAfterRender(IRequestCycle cycle)
Invoked by render(IMarkupWriter, IRequestCycle)
after the component renders, to clear any parameters back to
null (or 0, or false, or whatever the correct default is). |
protected void |
finishLoad()
Invoked, as a convienience, from finishLoad(IRequestCycle, IPageLoader, IComponentSpecification). |
void |
finishLoad(IRequestCycle cycle,
IPageLoader loader,
IComponentSpecification specification)
Registers this component as a listener of the page if it implements PageDetachListener or
PageRenderListener. |
protected void |
fireObservedChange(String propertyName,
boolean newValue)
Deprecated. To be removed in 3.1. Use Tapestry.fireObservedChange(IComponent, String, boolean) instead. |
protected void |
fireObservedChange(String propertyName,
byte newValue)
Deprecated. To be removed in 3.1. Use Tapestry.fireObservedChange(IComponent, String, byte) instead. |
protected void |
fireObservedChange(String propertyName,
char newValue)
Deprecated. To be removed in 3.1. Use Tapestry.fireObservedChange(IComponent, String, char) instead. |
protected void |
fireObservedChange(String propertyName,
double newValue)
Deprecated. To be removed in 3.1. Use Tapestry.fireObservedChange(IComponent, String, double) instead. |
protected void |
fireObservedChange(String propertyName,
float newValue)
Deprecated. To be removed in 3.1. Use Tapestry.fireObservedChange(IComponent, String, float) instead. |
protected void |
fireObservedChange(String propertyName,
int newValue)
Deprecated. To be removed in 3.1. Use Tapestry.fireObservedChange(IComponent, String, int) instead. |
protected void |
fireObservedChange(String propertyName,
long newValue)
Deprecated. To be removed in 3.1. Use Tapestry.fireObservedChange(IComponent, String, long) instead. |
protected void |
fireObservedChange(String propertyName,
Object newValue)
Deprecated. To be removed in 3.1. Use Tapestry.fireObservedChange(IComponent, String, Object) instead. |
protected void |
fireObservedChange(String propertyName,
short newValue)
Deprecated. To be removed in 3.1. Use Tapestry.fireObservedChange(IComponent, String, short) instead. |
String |
format(String key,
Object argument)
Convienience method for invoking IMessages.format(String, Object) |
String |
format(String key,
Object[] arguments)
Formats a localized message string, using IMessages.format(java.lang.String, java.lang.Object[]). |
String |
format(String key,
Object argument1,
Object argument2)
Convienience method for invoking IMessages.format(String, Object, Object). |
String |
format(String key,
Object argument1,
Object argument2,
Object argument3)
Convienience method for IMessages.format(String, Object, Object, Object). |
String |
formatString(String key,
Object argument)
Deprecated. To be removed in 3.1. Use format(String, Object) instead. |
String |
formatString(String key,
Object[] arguments)
Deprecated. To be removed in 3.1. Use format(String, Object[]) instead. |
String |
formatString(String key,
Object argument1,
Object argument2)
Deprecated. To be removed in 3.1. Use format(String, Object, Object) instead. |
String |
formatString(String key,
Object argument1,
Object argument2,
Object argument3)
Deprecated. To be removed in 3.1. Use format(String, Object, Object, Object) instead. |
protected void |
generateAttributes(IMarkupWriter writer,
IRequestCycle cycle)
Deprecated. To be removed in 3.1. Use renderInformalParameters(IMarkupWriter, IRequestCycle)
instead. |
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 a 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. |
ChangeObserver |
getChangeObserver()
Deprecated. To be removed in 3.1; use IPage.getChangeObserver(). |
IComponent |
getComponent(String id)
Retrieves an contained component by its id. |
Map |
getComponents()
Returns an unmodifiable Map of components, keyed on component id. |
IComponent |
getContainer()
Returns the component which embeds the receiver. |
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. |
ListenerMap |
getListeners()
Returns a ListenerMap for the component. |
String |
getMessage(String key)
Returns a localized string message. |
IMessages |
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. |
Object |
getProperty(String propertyName)
Gets a property of a component. |
IComponentSpecification |
getSpecification()
Returns the specification which defines the component. |
String |
getString(String key)
Obtains the IMessages for this component
(if necessary), and gets the string from it. |
void |
pageEndRender(PageEvent event)
Empty implementation of PageRenderListener.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(String name,
IBinding binding)
Adds the binding with the given name, replacing any existing binding with that name. |
void |
setContainer(IComponent value)
Sets the container of the component. |
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 |
setProperty(String propertyName,
Object value)
Sets a property of a component. |
void |
setSpecification(IComponentSpecification value)
Sets the specification used by the component. |
String |
toString()
|
| Methods inherited from class org.apache.tapestry.spec.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.tapestry.ILocationHolder |
|---|
setLocation |
| Methods inherited from interface org.apache.tapestry.ILocatable |
|---|
getLocation |
| Constructor Detail |
|---|
public AbstractComponent()
| Method Detail |
|---|
public void addAsset(String name,
IAsset asset)
IComponent
addAsset in interface IComponentpublic void addComponent(IComponent component)
IComponent
addComponent in interface IComponentIPageLoaderpublic void addBody(IRender element)
renderBody(IMarkupWriter, IRequestCycle).
addBody in interface IComponent
public void finishLoad(IRequestCycle cycle,
IPageLoader loader,
IComponentSpecification specification)
PageDetachListener or
PageRenderListener.
Invokes finishLoad(). Subclasses may overide as needed, but
must invoke this implementation.
BaseComponent
loads its HTML template.
finishLoad in interface IComponent
protected void fireObservedChange(String propertyName,
int newValue)
Tapestry.fireObservedChange(IComponent, String, int) instead.
protected void fireObservedChange(String propertyName,
Object newValue)
Tapestry.fireObservedChange(IComponent, String, Object) instead.
protected void fireObservedChange(String propertyName,
boolean newValue)
Tapestry.fireObservedChange(IComponent, String, boolean) instead.
protected void fireObservedChange(String propertyName,
double newValue)
Tapestry.fireObservedChange(IComponent, String, double) instead.
protected void fireObservedChange(String propertyName,
float newValue)
Tapestry.fireObservedChange(IComponent, String, float) instead.
protected void fireObservedChange(String propertyName,
long newValue)
Tapestry.fireObservedChange(IComponent, String, long) instead.
protected void fireObservedChange(String propertyName,
char newValue)
Tapestry.fireObservedChange(IComponent, String, char) instead.
protected void fireObservedChange(String propertyName,
byte newValue)
Tapestry.fireObservedChange(IComponent, String, byte) instead.
protected void fireObservedChange(String propertyName,
short newValue)
Tapestry.fireObservedChange(IComponent, String, short) instead.
protected void generateAttributes(IMarkupWriter writer,
IRequestCycle cycle)
renderInformalParameters(IMarkupWriter, IRequestCycle)
instead.
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 when the name matches a formal parameter (as of 1.0.5, informal bindings are weeded out at page load / template load time, if they match a formal parameter, or a specificied reserved name). For the most part, all the bindings here are either informal parameter, or formal parameter without a corresponding JavaBeans property.
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(IRequestCycle) 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(String name)
This method looks for a JavaBeans property with an
appropriate name, of type IBinding. The property
should be named nameBinding. If it exists
and is both readable and writable, then it is accessor method
is invoked. Components which implement such methods can
access their own binding through their instance variables
instead of invoking this method, a performance optimization.
getBinding in interface IComponentsetBinding(String,IBinding)public ChangeObserver getChangeObserver()
IPage.getChangeObserver().
IPageRecorder.
IPage.getChangeObserver()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 getId()
IComponentAn id will be unique within the component which contains this component.
A page will 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 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 IComponentIComponent.getId()public IPage getPage()
IComponent
getPage in interface IComponentpublic void setPage(IPage value)
IComponentApplicationRuntimeException.
setPage in interface IComponentpublic IComponentSpecification getSpecification()
IComponent
getSpecification in interface IComponentpublic void setSpecification(IComponentSpecification value)
IComponentApplicationRuntimeException.
setSpecification in interface IComponent
public void renderBody(IMarkupWriter writer,
IRequestCycle cycle)
renderBody in interface IComponent
public void setBinding(String name,
IBinding binding)
This method checks to see if a matching JavaBeans property
(with a name of nameBinding and a type of
IBinding) exists. If so, that property is updated.
An optimized component can simply implement accessor and
mutator methods and then access its bindings via its own
instance variables, rather than going through getBinding(String).
Informal parameters should not be stored in
instance variables if renderInformalParameters(IMarkupWriter, IRequestCycle) is to be used.
It relies on using the collection of bindings (to store informal parameters).
setBinding in interface IComponentIPageLoaderpublic String toString()
toString in class Objectpublic 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 IComponentpublic Map getAssets()
IComponentThe return value is unmodifiable.
getAssets in interface IComponentpublic IAsset getAsset(String name)
IComponent
getAsset in interface IComponentpublic Collection getBindingNames()
IComponentCollection 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 IComponentpublic Map getBindings()
Map of all bindings for this component. This implementation
is expensive, since it has to merge the disassociated bindings (informal parameters,
and parameters without a JavaBeans property) with the associated bindings (formal
parameters with a JavaBeans property).
getBindings in interface IComponentpublic 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.
public IBeanProvider getBeans()
IBeanProvider for this component. This is lazily created the
first time it is needed.
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 IRenderprotected void prepareForRender(IRequestCycle cycle)
render(IMarkupWriter, IRequestCycle)
to prepare the component to render. This implementation
sets JavaBeans properties from matching bound parameters.
Subclasses that override this method must invoke this
implementation as well.
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, to clear any parameters back to
null (or 0, or false, or whatever the correct default is).
Primarily, this is used to ensure
that the component doesn't hold onto any objects that could
otherwise be garbage collected.
Subclasses may override this implementation, but must also invoke it.
public IMessages getMessages()
IComponent
getMessages in interface IComponentpublic String getString(String key)
IMessages for this component
(if necessary), and gets the string from it.
getString in interface IComponentkey - the key used to locate the message
public String getMessage(String key)
IComponent
getMessage in interface IComponentkey - the key used to locate the message
public String formatString(String key,
Object[] arguments)
format(String, Object[]) instead.
IMessages.format(java.lang.String, java.lang.Object[]).
key - the key used to obtain a localized pattern using
getString(String)arguments - passed to the formatter
public String format(String key,
Object[] arguments)
IMessages.format(java.lang.String, java.lang.Object[]).
key - the key used to obtain a localized pattern using
getString(String)arguments - passed to the formatter
public String formatString(String key,
Object argument)
format(String, Object) instead.
IMessages.format(String, Object[])
public String format(String key,
Object argument)
IMessages.format(String, Object)
public String formatString(String key,
Object argument1,
Object argument2)
format(String, Object, Object) instead.
IMessages.format(String, Object, Object).
public String format(String key,
Object argument1,
Object argument2)
IMessages.format(String, Object, Object).
public String formatString(String key,
Object argument1,
Object argument2,
Object argument3)
format(String, Object, Object, Object) instead.
IMessages.format(String, Object, Object, Object).
public String format(String key,
Object argument1,
Object argument2,
Object argument3)
IMessages.format(String, Object, Object, Object).
public INamespace getNamespace()
IComponentINamespace in which the component was defined
(as an alias).
getNamespace in interface IComponentpublic void setNamespace(INamespace namespace)
IComponentINamespace for 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)
PageRenderListener.pageEndRender(PageEvent).
This allows classes to implement
PageRenderListener and only
implement the
PageRenderListener.pageBeginRender(PageEvent)
method.
public void setProperty(String propertyName,
Object value)
setProperty in interface IComponentpropertyName - the property namevalue - the provided valueIComponentpublic Object getProperty(String propertyName)
getProperty in interface IComponentpropertyName - the property name
IComponent
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||