public class InternalComponentResourcesImpl extends LockSupport implements InternalComponentResources
ComponentPageElement, that supplies all kinds of
resources to the
component, including access to its parameters, parameter bindings, and persistent field data.| Constructor and Description |
|---|
InternalComponentResourcesImpl(Page page,
ComponentPageElement element,
ComponentResources containerResources,
ComponentPageElementResources elementResources,
String completeId,
String nestedId,
Instantiator componentInstantiator,
boolean mixin) |
| Modifier and Type | Method and Description |
|---|---|
void |
addPageLifecycleListener(PageLifecycleListener listener)
Adds a listener object that will be notified about page lifecycle events.
|
void |
addPageResetListener(PageResetListener listener)
|
void |
bindParameter(String parameterName,
Binding binding)
Used during construction of the page to identify the binding for a particular parameter.
|
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.
|
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.
|
Type |
getBoundGenericType(String parameterName)
Returns the generic type of the bound parameter, or null if the parameter is not bound.
|
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.
|
<T> T |
getInformalParameter(String name,
Class<T> type)
Reads an informal parameter and coerces 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 concatenated 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.
|
<T extends Annotation> |
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 convenience method for invoking
ComponentResourcesCommon.triggerContextEvent(String, EventContext , ComponentEventCallback). |
acquireReadLock, downgradeWriteLockToReadLock, releaseReadLock, releaseWriteLock, takeWriteLock, upgradeReadLockToWriteLockpublic InternalComponentResourcesImpl(Page page, ComponentPageElement element, ComponentResources containerResources, ComponentPageElementResources elementResources, String completeId, String nestedId, Instantiator componentInstantiator, boolean mixin)
public boolean isMixin()
ComponentResourcesisMixin in interface ComponentResourcespublic Location getLocation()
LocatablegetLocation in interface Locatablepublic ComponentModel getComponentModel()
ComponentResourcesgetComponentModel in interface ComponentResourcespublic Component getEmbeddedComponent(String embeddedId)
ComponentResourcesgetEmbeddedComponent in interface ComponentResourcesembeddedId - selects the embedded component (case is ignored)public Object getFieldChange(String fieldName)
InternalComponentResourcesgetFieldChange in interface InternalComponentResourcesfieldName - the name of the field to accesspublic String getId()
ComponentResourcesCommongetId in interface ComponentResourcesCommonpublic boolean hasFieldChange(String fieldName)
InternalComponentResourceshasFieldChange in interface InternalComponentResourcespublic Link createEventLink(String eventType, Object... context)
ComponentResourcesCommoncreateEventLink 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 encodedpublic Link createFormEventLink(String eventType, Object... context)
ComponentResourcesCommoncreateFormEventLink 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 encodedpublic void discardPersistentFieldChanges()
ComponentResourcesSession) which will take effect in the
next request (the attached page instance is not affected).discardPersistentFieldChanges in interface ComponentResourcespublic String getElementName()
ComponentResourcesgetElementName in interface ComponentResourcespublic List<String> getInformalParameterNames()
ComponentResourcesgetInformalParameterNames in interface ComponentResourcesSupportsInformalParameterspublic <T> T getInformalParameter(String name, Class<T> type)
ComponentResourcesgetInformalParameter in interface ComponentResourcesname - name of informal parametertype - output value typepublic Block getBody()
ComponentResourcesCommongetBody in interface ComponentResourcesCommonpublic boolean hasBody()
ComponentResourcesCommonhasBody 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()
ComponentResourcesgetComponent in interface ComponentResourcespublic boolean isBound(String parameterName)
ComponentResourcesisBound in interface ComponentResourcespublic <T extends Annotation> T getParameterAnnotation(String parameterName, Class<T> annotationType)
ComponentResourcesgetParameterAnnotation in interface ComponentResourcesparameterName - name of parameter to search for the annotationannotationType - the type of annotationpublic boolean isRendering()
ComponentResourcesCommonisRendering in interface ComponentResourcesCommonpublic 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,
OnEventpublic boolean triggerContextEvent(String eventType, EventContext context, ComponentEventCallback callback)
ComponentResourcesCommontriggerContextEvent 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()
ComponentResourcesCommongetNestedId in interface ComponentResourcesCommonpublic Component getPage()
ComponentResourcesgetPage in interface ComponentResourcespublic boolean isLoaded()
InternalComponentResourcesCommonisLoaded in interface InternalComponentResourcesCommonPageLifecycleListener.containingPageDidLoad()public void persistFieldChange(String fieldName, Object newValue)
InternalComponentResourcespage to the PersistentFieldManager.persistFieldChange in interface InternalComponentResourcespublic void bindParameter(String parameterName, Binding binding)
InternalComponentResourcesCommonbindParameter in interface InternalComponentResourcesCommonpublic Class getBoundType(String parameterName)
ComponentResourcesgetBoundType in interface ComponentResourcesparameterName - used to select the parameter (case is ignored)Binding.getBindingType()public Type getBoundGenericType(String parameterName)
ComponentResourcesgetBoundGenericType in interface ComponentResourcesparameterName - used to select the parameter (case is ignored)Binding.getBindingType()public Binding getBinding(String parameterName)
InternalComponentResourcesCommongetBinding in interface InternalComponentResourcesCommonparameterName - name of component parameterpublic AnnotationProvider getAnnotationProvider(String parameterName)
ComponentResourcesgetAnnotationProvider in interface ComponentResourcesparameterName - used to select the parameter (case is ignored)public org.slf4j.Logger getLogger()
ComponentResourcesCommongetLogger in interface ComponentResourcesCommonComponentModel.getLogger()public Component getMixinByClassName(String mixinClassName)
InternalComponentResourcesCommongetMixinByClassName in interface InternalComponentResourcesCommonmixinClassName - fully qualified class namepublic void renderInformalParameters(MarkupWriter writer)
ComponentResourcesrenderInformalParameters in interface ComponentResourceswriter - to which attributes will be writtenpublic Component getContainer()
ComponentResourcesgetContainer 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()
ComponentResourcesCommongetLocale in interface ComponentResourcesCommonComponentResourcesCommon.getResourceSelector()public ComponentResourceSelector getResourceSelector()
ComponentResourcesCommongetResourceSelector in interface ComponentResourcesCommonpublic Messages getMessages()
ComponentResourcesgetMessages in interface ComponentResourcespublic String getElementName(String defaultElementName)
ComponentResourcesCommongetElementName in interface ComponentResourcesCommondefaultElementName - element name to return if the element name is not known (may be null)public Block getBlock(String blockId)
ComponentResourcesCommongetBlock in interface ComponentResourcesCommonblockId - the id of the block (case insensitive)ComponentResourcesCommon.findBlock(String)public Block getBlockParameter(String parameterName)
ComponentResourcesgetBlockParameter 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()
ComponentResourcesgetBaseResource in interface ComponentResourcespublic String getPageName()
ComponentResourcesCommongetPageName in interface ComponentResourcesCommonpublic Map<String,Binding> getInformalParameterBindings()
InternalComponentResourcesCommongetInformalParameterBindings in interface InternalComponentResourcesCommonpublic Object getRenderVariable(String name)
ComponentResourcesgetRenderVariable in interface ComponentResourcesname - of the variable (case will be ignored)public void storeRenderVariable(String name, Object value)
ComponentResourcesstoreRenderVariable in interface ComponentResourcesname - of value to storevalue - value to store (may not be null)public void postRenderCleanup()
InternalComponentResourcespostRenderCleanup in interface InternalComponentResourcespublic void addPageLifecycleListener(PageLifecycleListener listener)
ComponentResourcesaddPageLifecycleListener in interface ComponentResourcespublic void removePageLifecycleListener(PageLifecycleListener listener)
ComponentResourcesremovePageLifecycleListener in interface ComponentResourcespublic void addPageResetListener(PageResetListener listener)
InternalComponentResourcesaddPageResetListener in interface InternalComponentResourceslistener - to registerpublic ParameterConduit getParameterConduit(String parameterName)
InternalComponentResourcesgetParameterConduit in interface InternalComponentResourcespublic 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 parameterpublic void render(MarkupWriter writer, RenderQueue queue)
RenderCommandrender in interface RenderCommandpublic PageLifecycleCallbackHub getPageLifecycleCallbackHub()
ComponentResourcesgetPageLifecycleCallbackHub in interface ComponentResources5.6.4 - Copyright © 2003-2021 The Apache Software Foundation.