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, upgradeReadLockToWriteLock
public InternalComponentResourcesImpl(Page page, ComponentPageElement element, ComponentResources containerResources, ComponentPageElementResources elementResources, String completeId, String nestedId, Instantiator componentInstantiator, boolean mixin)
public boolean isMixin()
ComponentResources
isMixin
in interface ComponentResources
public Location getLocation()
Locatable
getLocation
in interface Locatable
public ComponentModel getComponentModel()
ComponentResources
getComponentModel
in interface ComponentResources
public Component getEmbeddedComponent(String embeddedId)
ComponentResources
getEmbeddedComponent
in interface ComponentResources
embeddedId
- selects the embedded component (case is ignored)public Object getFieldChange(String fieldName)
InternalComponentResources
getFieldChange
in interface InternalComponentResources
fieldName
- the name of the field to accesspublic String getId()
ComponentResourcesCommon
getId
in interface ComponentResourcesCommon
public boolean hasFieldChange(String fieldName)
InternalComponentResources
hasFieldChange
in interface InternalComponentResources
public Link createEventLink(String eventType, Object... context)
ComponentResourcesCommon
createEventLink
in interface ComponentResourcesCommon
eventType
- 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)
ComponentResourcesCommon
createFormEventLink
in interface ComponentResourcesCommon
eventType
- 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()
ComponentResources
Session
) which will take effect in the
next request (the attached page instance is not affected).discardPersistentFieldChanges
in interface ComponentResources
public String getElementName()
ComponentResources
getElementName
in interface ComponentResources
public List<String> getInformalParameterNames()
ComponentResources
getInformalParameterNames
in interface ComponentResources
SupportsInformalParameters
public <T> T getInformalParameter(String name, Class<T> type)
ComponentResources
getInformalParameter
in interface ComponentResources
name
- name of informal parametertype
- output value typepublic Block getBody()
ComponentResourcesCommon
getBody
in interface ComponentResourcesCommon
public boolean hasBody()
ComponentResourcesCommon
hasBody
in interface ComponentResourcesCommon
public String getCompleteId()
ComponentResourcesCommon
nested 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 ComponentResourcesCommon
ComponentSource.getComponent(String)
public Component getComponent()
ComponentResources
getComponent
in interface ComponentResources
public boolean isBound(String parameterName)
ComponentResources
isBound
in interface ComponentResources
public <T extends Annotation> T getParameterAnnotation(String parameterName, Class<T> annotationType)
ComponentResources
getParameterAnnotation
in interface ComponentResources
parameterName
- name of parameter to search for the annotationannotationType
- the type of annotationpublic boolean isRendering()
ComponentResourcesCommon
isRendering
in interface ComponentResourcesCommon
public boolean triggerEvent(String eventType, Object[] context, ComponentEventCallback handler)
ComponentResourcesCommon
ComponentResourcesCommon.triggerContextEvent(String, EventContext , ComponentEventCallback)
. Wraps
the context values into an EventContext
.triggerEvent
in interface ComponentResourcesCommon
eventType
- 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 ComponentResourcesCommon
eventType
- 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
,
OnEvent
public String getNestedId()
ComponentResourcesCommon
getNestedId
in interface ComponentResourcesCommon
public Component getPage()
ComponentResources
getPage
in interface ComponentResources
public boolean isLoaded()
InternalComponentResourcesCommon
isLoaded
in interface InternalComponentResourcesCommon
PageLifecycleListener.containingPageDidLoad()
public void persistFieldChange(String fieldName, Object newValue)
InternalComponentResources
page
to the PersistentFieldManager
.persistFieldChange
in interface InternalComponentResources
public void bindParameter(String parameterName, Binding binding)
InternalComponentResourcesCommon
bindParameter
in interface InternalComponentResourcesCommon
public Class getBoundType(String parameterName)
ComponentResources
getBoundType
in interface ComponentResources
parameterName
- used to select the parameter (case is ignored)Binding.getBindingType()
public Type getBoundGenericType(String parameterName)
ComponentResources
getBoundGenericType
in interface ComponentResources
parameterName
- used to select the parameter (case is ignored)Binding.getBindingType()
public Binding getBinding(String parameterName)
InternalComponentResourcesCommon
getBinding
in interface InternalComponentResourcesCommon
parameterName
- name of component parameterpublic AnnotationProvider getAnnotationProvider(String parameterName)
ComponentResources
getAnnotationProvider
in interface ComponentResources
parameterName
- used to select the parameter (case is ignored)public org.slf4j.Logger getLogger()
ComponentResourcesCommon
getLogger
in interface ComponentResourcesCommon
ComponentModel.getLogger()
public Component getMixinByClassName(String mixinClassName)
InternalComponentResourcesCommon
getMixinByClassName
in interface InternalComponentResourcesCommon
mixinClassName
- fully qualified class namepublic void renderInformalParameters(MarkupWriter writer)
ComponentResources
renderInformalParameters
in interface ComponentResources
writer
- to which attributes
will be writtenpublic Component getContainer()
ComponentResources
getContainer
in interface ComponentResources
public ComponentResources getContainerResources()
ComponentResources
ComponentResources
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 ComponentResources
public Messages getContainerMessages()
ComponentResources
Messages
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 ComponentResources
public Locale getLocale()
ComponentResourcesCommon
getLocale
in interface ComponentResourcesCommon
ComponentResourcesCommon.getResourceSelector()
public ComponentResourceSelector getResourceSelector()
ComponentResourcesCommon
getResourceSelector
in interface ComponentResourcesCommon
public Messages getMessages()
ComponentResources
getMessages
in interface ComponentResources
public String getElementName(String defaultElementName)
ComponentResourcesCommon
getElementName
in interface ComponentResourcesCommon
defaultElementName
- element name to return if the element name is not known (may be null)public Block getBlock(String blockId)
ComponentResourcesCommon
getBlock
in interface ComponentResourcesCommon
blockId
- the id of the block (case insensitive)ComponentResourcesCommon.findBlock(String)
public Block getBlockParameter(String parameterName)
ComponentResources
getBlockParameter
in interface ComponentResources
parameterName
- the name of the informal parameter (case is ignored)public Block findBlock(String blockId)
ComponentResourcesCommon
ComponentResourcesCommon.getBlock(String)
, but returns null if the block is not found.findBlock
in interface ComponentResourcesCommon
blockId
- the id of the block (case insensitive)public Resource getBaseResource()
ComponentResources
getBaseResource
in interface ComponentResources
public String getPageName()
ComponentResourcesCommon
getPageName
in interface ComponentResourcesCommon
public Map<String,Binding> getInformalParameterBindings()
InternalComponentResourcesCommon
getInformalParameterBindings
in interface InternalComponentResourcesCommon
public Object getRenderVariable(String name)
ComponentResources
getRenderVariable
in interface ComponentResources
name
- of the variable (case will be ignored)public void storeRenderVariable(String name, Object value)
ComponentResources
storeRenderVariable
in interface ComponentResources
name
- of value to storevalue
- value to store (may not be null)public void postRenderCleanup()
InternalComponentResources
postRenderCleanup
in interface InternalComponentResources
public void addPageLifecycleListener(PageLifecycleListener listener)
ComponentResources
addPageLifecycleListener
in interface ComponentResources
public void removePageLifecycleListener(PageLifecycleListener listener)
ComponentResources
removePageLifecycleListener
in interface ComponentResources
public void addPageResetListener(PageResetListener listener)
InternalComponentResources
addPageResetListener
in interface InternalComponentResources
listener
- to registerpublic ParameterConduit getParameterConduit(String parameterName)
InternalComponentResources
getParameterConduit
in interface InternalComponentResources
public void setParameterConduit(String parameterName, ParameterConduit conduit)
InternalComponentResources
PageLifecycleListener.containingPageDidLoad()
lifecycle
method.setParameterConduit
in interface InternalComponentResources
public String getPropertyName(String parameterName)
InternalComponentResources
PropBinding
is used and the expression points to a property on a bean (e.g. user.name).
Otherwise this method returns null.getPropertyName
in interface InternalComponentResources
parameterName
- name of the parameterpublic void render(MarkupWriter writer, RenderQueue queue)
RenderCommand
render
in interface RenderCommand
public PageLifecycleCallbackHub getPageLifecycleCallbackHub()
ComponentResources
getPageLifecycleCallbackHub
in interface ComponentResources
${project.version} - Copyright © 2003-2015 The Apache Software Foundation.