|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.primix.tapestry.AbstractComponent
Abstract base class implementing the IComponent
interface.
Field Summary | |
protected java.lang.String |
id
The simple id of this component. |
protected IPage |
page
The page that contains the component, possibly itself (if the component is in fact, a page). |
protected ComponentSpecification |
specification
The specification used to originally build the component. |
protected IRender[] |
wrapped
An aray of elements wrapped by this component. |
protected int |
wrappedCount
The number of IRender objects wrapped by
this component. |
Constructor Summary | |
AbstractComponent()
|
Method Summary | |
void |
addAsset(java.lang.String name,
IAsset asset)
Adds an asset to the component. |
void |
addComponent(IComponent component)
Adds a component to a container. |
void |
addWrapped(IRender element)
Adds an element (which may be static text or a component) as a wrapped element of this component. |
void |
cleanupAfterRender(IRequestCycle cycle)
Does nothing. |
void |
cleanupComponent()
Does nothing. |
protected void |
finishLoad()
Invoked from finishLoad(IPageLoader, ComponentSpecification)
so that components can easily perform simple operations, such as
registering for event notifications. |
void |
finishLoad(IPageLoader loader,
ComponentSpecification specification)
Invokes finishLoad() . |
protected void |
fireObservedChange()
Fires a change event for no single property; the receiver should note that the page containing the component is 'dirty' even if no property appears to have changed. |
protected void |
fireObservedChange(java.lang.String propertyName,
boolean newValue)
|
protected void |
fireObservedChange(java.lang.String propertyName,
byte newValue)
|
protected void |
fireObservedChange(java.lang.String propertyName,
char newValue)
|
protected void |
fireObservedChange(java.lang.String propertyName,
double newValue)
|
protected void |
fireObservedChange(java.lang.String propertyName,
float newValue)
|
protected void |
fireObservedChange(java.lang.String propertyName,
int newValue)
|
protected void |
fireObservedChange(java.lang.String propertyName,
long newValue)
|
protected void |
fireObservedChange(java.lang.String propertyName,
java.lang.Object newValue)
|
protected void |
fireObservedChange(java.lang.String propertyName,
short newValue)
|
protected void |
generateAttributes(IResponseWriter writer,
IRequestCycle cycle)
Converts informal parameters into additional attributes on the curently open tag. |
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 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 a Map of all bindings for this component. |
ChangeObserver |
getChangeObserver()
Return's the page's change observer. |
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. |
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. |
IPage |
getPage()
Returns the page which ultimately contains the receiver. |
ComponentSpecification |
getSpecification()
Returns the specification which defines the component. |
void |
prepareForRender(IRequestCycle cycle)
Does nothing. |
void |
renderWrapped(IResponseWriter writer,
IRequestCycle cycle)
Renders all elements wrapped by the receiver. |
void |
reset()
Does nothing. |
void |
setBinding(java.lang.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(java.lang.String value)
Sets the id of the component. |
void |
setPage(IPage value)
Sets the page which ultimiately contains the component. |
void |
setSpecification(ComponentSpecification value)
Sets the specification used by the component. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface com.primix.tapestry.IRender |
render |
Field Detail |
protected ComponentSpecification specification
protected IPage page
protected java.lang.String id
protected int wrappedCount
IRender
objects wrapped by
this component.protected IRender[] wrapped
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
com.primix.tapestry.IComponent
IPageLoader
public void addWrapped(IRender element)
renderWrapped(IResponseWriter, IRequestCycle)
.addWrapped
in interface IComponent
public void finishLoad(IPageLoader loader, ComponentSpecification specification) throws PageLoaderException
finishLoad()
. Subclasses may overide as needed, but
must invoke this implementation (or finishLoad()
.
BaseComponent
loads its HTML template.finishLoad
in interface IComponent
protected void fireObservedChange(java.lang.String propertyName, int newValue)
protected void fireObservedChange(java.lang.String propertyName, java.lang.Object newValue)
protected void fireObservedChange(java.lang.String propertyName, boolean newValue)
protected void fireObservedChange(java.lang.String propertyName, double newValue)
protected void fireObservedChange(java.lang.String propertyName, float newValue)
protected void fireObservedChange(java.lang.String propertyName, long newValue)
protected void fireObservedChange(java.lang.String propertyName, char newValue)
protected void fireObservedChange(java.lang.String propertyName, byte newValue)
protected void fireObservedChange(java.lang.String propertyName, short newValue)
protected void fireObservedChange()
protected void generateAttributes(IResponseWriter 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, IResponseWriter.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)
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 IComponent
setBinding(String,IBinding)
public ChangeObserver getChangeObserver()
IPageRecorder
.IPage.getChangeObserver()
public IComponent getComponent(java.lang.String id)
IComponent
getComponent
in interface IComponent
com.primix.tapestry.IComponent
NoSuchComponentException
- runtime exception thrown if the named
component does not exist.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
com.primix.tapestry.IComponent
IComponent.getId()
public IPage getPage()
IComponent
getPage
in interface IComponent
public void setPage(IPage value)
IComponent
ApplicationRuntimeException
.setPage
in interface IComponent
public ComponentSpecification getSpecification()
IComponent
getSpecification
in interface IComponent
public void setSpecification(ComponentSpecification value)
IComponent
ApplicationRuntimeException
.setSpecification
in interface IComponent
public void renderWrapped(IResponseWriter writer, IRequestCycle cycle) throws RequestCycleException
renderWrapped
in interface IComponent
public void setBinding(java.lang.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 @link #generateAttribute(IResponseWriter, String[]) is to be used. It relies on using the collection of bindings (to store informal parameters).
setBinding
in interface IComponent
com.primix.tapestry.IComponent
IPageLoader
public java.lang.String toString()
toString
in class java.lang.Object
public java.util.Map getComponents()
Map
of components, keyed on component id.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. 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 IComponent
public ListenerMap getListeners()
ListenerMap
for the component. A ListenerMap
contains a number of
synthetic read-only properties that implement the IActionListener
and/or IDirectListener
interfaces, 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(IPageLoader, ComponentSpecification)
so that components can easily perform simple operations, such as
registering for event notifications. This is a convienience,
providing a much simpler method signature to override.
This implementation checks to
see if the component implements ILifecycle
, if
so, the component sets up listeners to invoke
the implementations of the ILifecycle
methods. This support
will be removed in release 1.1.
public void cleanupAfterRender(IRequestCycle cycle)
finishLoad()
,
ILifecycle
public void prepareForRender(IRequestCycle cycle)
finishLoad()
,
ILifecycle
public void reset()
finishLoad()
,
ILifecycle
public void cleanupComponent()
finishLoad()
,
ILifecycle
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |