|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.tapestry5.ioc.internal.util.LockSupport
org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl
public class InternalComponentResourcesImpl
The bridge between a component and its ComponentPageElement, that supplies all kinds of
resources to the
component, including access to its parameters, parameter bindings, and persistent field data.
| Constructor Summary | |
|---|---|
InternalComponentResourcesImpl(Page page,
ComponentPageElement element,
ComponentResources containerResources,
ComponentPageElementResources elementResources,
String completeId,
String nestedId,
Instantiator componentInstantiator,
boolean mixin)
|
|
| Method Summary | ||
|---|---|---|
void |
addPageLifecycleListener(PageLifecycleListener listener)
Adds a listener object that will be notified about page lifecycle events. |
|
void |
addPageResetListener(PageResetListener listener)
Delegates to Page.addResetListener(org.apache.tapestry5.internal.structure.PageResetListener). |
|
void |
bindParameter(String parameterName,
Binding binding)
Used during construction of the page to identify the binding for a particular parameter. |
|
Link |
createActionLink(String eventType,
boolean forForm,
Object... context)
Creates a component event request link as a callback for this component. |
|
Link |
createEventLink(String eventType,
Object... context)
Creates a component event request link as a callback for this component. |
|
Link |
createFormEventLink(String eventType,
Object... context)
Creates a component event request link as a callback for this component. |
|
Link |
createPageLink(Class pageClass,
boolean override,
Object... context)
Creates a page render request link to render a specific page. |
|
Link |
createPageLink(String pageName,
boolean override,
Object... context)
Creates a page render request link to render a specific page. |
|
void |
discardPersistentFieldChanges()
Discards all persistent field changes for the page containing the component. |
|
Block |
findBlock(String blockId)
As with ComponentResourcesCommon.getBlock(String), but returns null if the block is not found. |
|
AnnotationProvider |
getAnnotationProvider(String parameterName)
Returns an annotation provider, used to obtain annotations related to the parameter. |
|
Resource |
getBaseResource()
Returns the base resource for the component, which will represent the class's location within the classpath (this is used to resolve relative assets). |
|
Binding |
getBinding(String parameterName)
Returns the binding for the given parameter name, or null. |
|
Block |
getBlock(String blockId)
Returns a block from the component's template, referenced by its id. |
|
Block |
getBlockParameter(String parameterName)
Used to access an informal parameter that's a Block. |
|
Block |
getBody()
Returns the body of this component as a (possibly empty) block. |
|
Class |
getBoundType(String parameterName)
Returns the actual type of the bound parameter, or null if the parameter is not bound. |
|
String |
getCompleteId()
Returns a string consisting of the logical name of the containing page, and the nested id
of this component, separated by a colon. |
|
Component |
getComponent()
Returns the component this object provides resources for. |
|
ComponentModel |
getComponentModel()
Returns the component model object that defines the behavior of the component. |
|
Component |
getContainer()
Returns the component which contains this component, or null for the root component. |
|
Messages |
getContainerMessages()
Returns the Messages from the container, or null if this is the root component (with no container). |
|
ComponentResources |
getContainerResources()
Returns the ComponentResources for the container, or null if the this is the root component (that has no
container). |
|
String |
getElementName()
Returns the name of element that represents the component in its template, or null if not known. |
|
String |
getElementName(String defaultElementName)
Returns the name of element that represents the component in its template, or the provided default element name if the element was a component type (in the Tapestry namespace). |
|
Component |
getEmbeddedComponent(String embeddedId)
Returns an embedded component, given the component's id. |
|
Object |
getFieldChange(String fieldName)
Get the current persisted value of the field. |
|
String |
getId()
Returns the simple (or local) id of the component. |
|
|
getInformalParameter(String name,
Class<T> type)
Reads an informal parameter and coercers the bound value to the indicated type. |
|
Map<String,Binding> |
getInformalParameterBindings()
Constructs a map linking informal parameters to the corresponding bindings. |
|
List<String> |
getInformalParameterNames()
Returns a list of the names of any informal parameters bound to this component. |
|
Locale |
getLocale()
Returns the locale for the page containing this component. |
|
Location |
getLocation()
Returns the location associated with this object for error reporting purposes. |
|
org.slf4j.Logger |
getLogger()
Returns the log instance associated with the component (which is based on the component or mixin's class name). |
|
Messages |
getMessages()
Returns the message catalog for this component. |
|
Component |
getMixinByClassName(String mixinClassName)
Returns the mixin instance for the fully qualfied mixin class name. |
|
String |
getNestedId()
Return a string consisting the concatinated ids of all containing components, separated by periods. |
|
Component |
getPage()
Returns the page that contains this component. |
|
PageLifecycleCallbackHub |
getPageLifecycleCallbackHub()
Provides access to an object that can be used to register callbacks for page lifecycle events. |
|
String |
getPageName()
Returns the logical name of the page containing this component. |
|
|
getParameterAnnotation(String parameterName,
Class<T> annotationType)
Obtains an annotation provided by a parameter. |
|
ParameterConduit |
getParameterConduit(String parameterName)
Gets a previously stored ParameterConduit, allowing PCs to be shared between a component and a mixin of that component. |
|
String |
getPropertyName(String parameterName)
Returns the name of the bound property if PropBinding is used and the expression points to a property on a bean (e.g. |
|
Object |
getRenderVariable(String name)
Returns a previously stored render variable. |
|
ComponentResourceSelector |
getResourceSelector()
Returns the selector used when constructing the component and its containing page. |
|
boolean |
hasBody()
Returns true if the element has a body and false otherwise. |
|
boolean |
hasFieldChange(String fieldName)
Checks to see if there is a value stored for the indicated field. |
|
boolean |
isBound(String parameterName)
Returns true if the named parameter is bound, false if not. |
|
boolean |
isLoaded()
Returns true if the component has finished loading. |
|
boolean |
isMixin()
Returns true if these resources represent a mixin to another component. |
|
boolean |
isRendering()
Returns true if the component is currently rendering, false otherwise. |
|
void |
persistFieldChange(String fieldName,
Object newValue)
Posts a change to a persistent field. |
|
void |
postRenderCleanup()
Allows the resources to cleanup any render-time only data. |
|
void |
removePageLifecycleListener(PageLifecycleListener listener)
Removes a previously added listener. |
|
void |
render(MarkupWriter writer,
RenderQueue queue)
Invoked on an object to request that it render itself. |
|
void |
renderInformalParameters(MarkupWriter writer)
Indentifies all parameters that are not formal parameters and writes each as a attribute/value pair into the current element of the markup writer. |
|
void |
setParameterConduit(String parameterName,
ParameterConduit conduit)
Stores a ParameterConduit for later access. |
|
void |
storeRenderVariable(String name,
Object value)
Stores a render variable, accessible with the provided name. |
|
String |
toString()
|
|
boolean |
triggerContextEvent(String eventType,
EventContext context,
ComponentEventCallback callback)
Triggers a component event. |
|
boolean |
triggerEvent(String eventType,
Object[] context,
ComponentEventCallback handler)
A convienience for invoking ComponentResourcesCommon.triggerContextEvent(String, EventContext , ComponentEventCallback). |
|
| Methods inherited from class org.apache.tapestry5.ioc.internal.util.LockSupport |
|---|
acquireReadLock, downgradeWriteLockToReadLock, releaseReadLock, releaseWriteLock, takeWriteLock, upgradeReadLockToWriteLock |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public InternalComponentResourcesImpl(Page page,
ComponentPageElement element,
ComponentResources containerResources,
ComponentPageElementResources elementResources,
String completeId,
String nestedId,
Instantiator componentInstantiator,
boolean mixin)
| Method Detail |
|---|
public boolean isMixin()
ComponentResources
isMixin in interface ComponentResourcespublic Location getLocation()
Locatable
getLocation in interface Locatablepublic String toString()
toString in class Objectpublic ComponentModel getComponentModel()
ComponentResources
getComponentModel in interface ComponentResourcespublic Component getEmbeddedComponent(String embeddedId)
ComponentResources
getEmbeddedComponent in interface ComponentResourcesembeddedId - selects the embedded component (case is ignored)public Object getFieldChange(String fieldName)
InternalComponentResources
getFieldChange in interface InternalComponentResourcesfieldName - the name of the field to access
public String getId()
ComponentResourcesCommon
getId in interface ComponentResourcesCommonpublic boolean hasFieldChange(String fieldName)
InternalComponentResources
hasFieldChange in interface InternalComponentResources
public Link createEventLink(String eventType,
Object... context)
ComponentResourcesCommon
createEventLink in interface ComponentResourcesCommoneventType - the type of event to be triggered. Event types should be Java identifiers (contain only
letters, numbers and the underscore).context - additional objects to be encoded into the path portion of the link; each is converted to a
string and URI encoded
public Link createActionLink(String eventType,
boolean forForm,
Object... context)
ComponentResourcesCommon
createActionLink in interface ComponentResourcesCommoneventType - the type of event to be triggered. Event types should be Java identifiers (contain only
letters, numbers and the underscore).forForm - if true, the link will be used as the eventType for an HTML form submission, which may affect
what information is encoded into the linkcontext - additional objects to be encoded into the path portion of the link; each is converted to a
string and URI encoded
public Link createFormEventLink(String eventType,
Object... context)
ComponentResourcesCommon
createFormEventLink in interface ComponentResourcesCommoneventType - the type of event to be triggered. Event types should be Java identifiers (contain only
letters, numbers and the underscore).context - additional objects to be encoded into the path portion of the link; each is converted to a
string and URI encoded
public Link createPageLink(String pageName,
boolean override,
Object... context)
ComponentResourcesCommon
createPageLink in interface ComponentResourcesCommonpageName - the logical name of the page to link tooverride - if true, the context is used even if empty (normally, the target page is allowed to passivate,
providing a context, when the provided context is empty)context - the activation context for the page. If omitted, the activation context is obtained from the
target page
public Link createPageLink(Class pageClass,
boolean override,
Object... context)
ComponentResourcesCommon
createPageLink in interface ComponentResourcesCommonpageClass - identifies the page to link tooverride - if true, the context is used even if empty (normally, the target page is allowed to passivate,
providing a context, when the provided context is empty)context - the activation context for the page. If omitted, the activation context is obtained from the
target page
public void discardPersistentFieldChanges()
ComponentResourcesSession) which will take effect in the
next request (the attached page instance is not affected).
discardPersistentFieldChanges in interface ComponentResourcespublic String getElementName()
ComponentResources
getElementName in interface ComponentResourcespublic List<String> getInformalParameterNames()
ComponentResources
getInformalParameterNames in interface ComponentResourcesSupportsInformalParameters
public <T> T getInformalParameter(String name,
Class<T> type)
ComponentResources
getInformalParameter in interface ComponentResourcesname - name of informal parametertype - output value type
public Block getBody()
ComponentResourcesCommon
getBody in interface ComponentResourcesCommonpublic boolean hasBody()
ComponentResourcesCommon
hasBody in interface ComponentResourcesCommonpublic String getCompleteId()
ComponentResourcesCommonnested id
of this component, separated by a colon. I.e., "MyPage:foo.bar.baz". For a page, returns just the page's name.
This value is often used to obtain an equivalent component instance in a later request.
getCompleteId in interface ComponentResourcesCommonComponentSource.getComponent(String)public Component getComponent()
ComponentResources
getComponent in interface ComponentResourcespublic boolean isBound(String parameterName)
ComponentResources
isBound in interface ComponentResources
public <T extends Annotation> T getParameterAnnotation(String parameterName,
Class<T> annotationType)
ComponentResources
getParameterAnnotation in interface ComponentResourcesparameterName - name of parameter to search for the annotationannotationType - the type of annotation
public boolean isRendering()
ComponentResourcesCommon
isRendering in interface ComponentResourcesCommon
public boolean triggerEvent(String eventType,
Object[] context,
ComponentEventCallback handler)
ComponentResourcesCommonComponentResourcesCommon.triggerContextEvent(String, EventContext , ComponentEventCallback). Wraps
the context values into an EventContext.
triggerEvent in interface ComponentResourcesCommoneventType - event type (as determined from the request, or otherwise by design)context - Values that may be provided to the event handler method as method parameters, or null if no
context values are availablehandler - the handler to be informed of the result, or null if the event is a notification that does
not support return values from event handler methods (the value true is allowed even if the
handler is null).
OnEventWorker,
OnEvent
public boolean triggerContextEvent(String eventType,
EventContext context,
ComponentEventCallback callback)
ComponentResourcesCommon
triggerContextEvent in interface ComponentResourcesCommoneventType - event type (as determined from the request, or otherwise by design)context - the context (as extracted from the request, or provided by the triggering component); these
values may be provided to event handler methods via their parameters (may not be null)callback - the handler to be informed of the result, or null if the event is a notification that does not
support return values from event handler methods (the value true is allowed even if the handler
is null).
OnEventWorker,
OnEventpublic String getNestedId()
ComponentResourcesCommon
getNestedId in interface ComponentResourcesCommonpublic Component getPage()
ComponentResources
getPage in interface ComponentResourcespublic boolean isLoaded()
InternalComponentResourcesCommon
isLoaded in interface InternalComponentResourcesCommonPageLifecycleListener.containingPageDidLoad()
public void persistFieldChange(String fieldName,
Object newValue)
InternalComponentResourcespage to the PersistentFieldManager.
persistFieldChange in interface InternalComponentResources
public void bindParameter(String parameterName,
Binding binding)
InternalComponentResourcesCommon
bindParameter in interface InternalComponentResourcesCommonpublic Class getBoundType(String parameterName)
ComponentResources
getBoundType in interface ComponentResourcesparameterName - used to select the parameter (case is ignored)
Binding.getBindingType()public Binding getBinding(String parameterName)
InternalComponentResourcesCommon
getBinding in interface InternalComponentResourcesCommonparameterName - name of component parameter
public AnnotationProvider getAnnotationProvider(String parameterName)
ComponentResources
getAnnotationProvider in interface ComponentResourcesparameterName - used to select the parameter (case is ignored)
public org.slf4j.Logger getLogger()
ComponentResourcesCommon
getLogger in interface ComponentResourcesCommonComponentModel.getLogger()public Component getMixinByClassName(String mixinClassName)
InternalComponentResourcesCommon
getMixinByClassName in interface InternalComponentResourcesCommonmixinClassName - fully qualified class name
public void renderInformalParameters(MarkupWriter writer)
ComponentResources
renderInformalParameters in interface ComponentResourceswriter - to which attributes will be writtenpublic Component getContainer()
ComponentResources
getContainer in interface ComponentResourcespublic ComponentResources getContainerResources()
ComponentResourcesComponentResources for the container, or null if the this is the root component (that has no
container). As a special case, for a mixin, this returns the core component's resources.
getContainerResources in interface ComponentResourcespublic Messages getContainerMessages()
ComponentResourcesMessages from the container, or null if this is the root component (with no container). As a
special case, for a mixin, this return the core component's messages.
getContainerMessages in interface ComponentResourcespublic Locale getLocale()
ComponentResourcesCommon
getLocale in interface ComponentResourcesCommonComponentResourcesCommon.getResourceSelector()public ComponentResourceSelector getResourceSelector()
ComponentResourcesCommon
getResourceSelector in interface ComponentResourcesCommonpublic Messages getMessages()
ComponentResources
getMessages in interface ComponentResourcespublic String getElementName(String defaultElementName)
ComponentResourcesCommon
getElementName in interface ComponentResourcesCommondefaultElementName - element name to return if the element name is not known (may be null)
public Block getBlock(String blockId)
ComponentResourcesCommon
getBlock in interface ComponentResourcesCommonblockId - the id of the block (case insensitive)
ComponentResourcesCommon.findBlock(String)public Block getBlockParameter(String parameterName)
ComponentResources
getBlockParameter in interface ComponentResourcesparameterName - the name of the informal parameter (case is ignored)
public Block findBlock(String blockId)
ComponentResourcesCommonComponentResourcesCommon.getBlock(String), but returns null if the block is not found.
findBlock in interface ComponentResourcesCommonblockId - the id of the block (case insensitive)
public Resource getBaseResource()
ComponentResources
getBaseResource in interface ComponentResourcespublic String getPageName()
ComponentResourcesCommon
getPageName in interface ComponentResourcesCommonpublic Map<String,Binding> getInformalParameterBindings()
InternalComponentResourcesCommon
getInformalParameterBindings in interface InternalComponentResourcesCommonpublic Object getRenderVariable(String name)
ComponentResources
getRenderVariable in interface ComponentResourcesname - of the variable (case will be ignored)
public void storeRenderVariable(String name,
Object value)
ComponentResources
storeRenderVariable in interface ComponentResourcesname - of value to storevalue - value to store (may not be null)public void postRenderCleanup()
InternalComponentResources
postRenderCleanup in interface InternalComponentResourcespublic void addPageLifecycleListener(PageLifecycleListener listener)
ComponentResources
addPageLifecycleListener in interface ComponentResourcespublic void removePageLifecycleListener(PageLifecycleListener listener)
ComponentResources
removePageLifecycleListener in interface ComponentResourcespublic void addPageResetListener(PageResetListener listener)
InternalComponentResourcesPage.addResetListener(org.apache.tapestry5.internal.structure.PageResetListener).
addPageResetListener in interface InternalComponentResourceslistener - to registerpublic ParameterConduit getParameterConduit(String parameterName)
InternalComponentResources
getParameterConduit in interface InternalComponentResources
public void setParameterConduit(String parameterName,
ParameterConduit conduit)
InternalComponentResourcesPageLifecycleListener.containingPageDidLoad() lifecycle
method.
setParameterConduit in interface InternalComponentResourcespublic String getPropertyName(String parameterName)
InternalComponentResourcesPropBinding is used and the expression points to a property on a bean (e.g. user.name).
Otherwise this method returns null.
getPropertyName in interface InternalComponentResourcesparameterName - name of the parameter
public void render(MarkupWriter writer,
RenderQueue queue)
RenderCommand
render in interface RenderCommandpublic PageLifecycleCallbackHub getPageLifecycleCallbackHub()
ComponentResources
getPageLifecycleCallbackHub in interface ComponentResources
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||