|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.tapestry5.ioc.BaseLocatable org.apache.tapestry5.internal.structure.ComponentPageElementImpl
public class ComponentPageElementImpl
Implements RenderCommand
and represents a component within an overall page. Much of a
component page
element's behavior is delegated to user code, via a Component
instance.
PageElementFactoryImpl
. There's still a bit of refactoring in this
class (and its many inner classes) that can improve overall efficiency.
Modified for Tapestry 5.2 to adjust for the no-pooling approach (shared instances with externalized mutable state).
Constructor Summary | |
---|---|
ComponentPageElementImpl(Page page,
Instantiator instantiator,
ComponentPageElementResources elementResources,
Request request,
SymbolSource symbolSource)
Constructor for the root component of a page. |
Method Summary | |
---|---|
void |
addBlock(String blockId,
Block block)
Used during the contruction of a page to add a non-anonymous Block to the component. |
void |
addMixin(String mixinId,
Instantiator instantiator,
String... order)
Adds a mixin. |
void |
addToBody(RenderCommand element)
Used during the construction of the page. |
void |
addToTemplate(RenderCommand element)
Used during the construction of a page. |
void |
bindMixinParameter(String mixinId,
String parameterName,
Binding binding)
|
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. |
protected RenderPhaseEvent |
createRenderEvent(RenderQueue queue)
|
boolean |
dispatchEvent(ComponentEvent event)
Asks each mixin and component to Component.dispatchComponentEvent(ComponentEvent) , returning true if any
handler was found. |
void |
enqueueBeforeRenderBody(RenderQueue queue)
Invoked when the component should render its body. |
Block |
findBlock(String id)
As with ComponentResourcesCommon.getBlock(String) , but returns null if the block is not found. |
Binding |
getBinding(String parameterName)
Returns the binding for the given parameter name, or null. |
Block |
getBlock(String id)
Returns a block from the component's template, referenced by its id. |
Block |
getBody()
Returns the body of this component as a (possibly empty) block. |
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 core component associated with this page element (as opposed to any mixins attached to the component). |
InternalComponentResources |
getComponentResources()
Returns the resources associated with the core component. |
ComponentPageElement |
getContainerElement()
Containing component (or null for the root component of a page). |
Page |
getContainingPage()
Returns the page which contains this component. |
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). |
ComponentPageElement |
getEmbeddedElement(String embeddedId)
Retrieves a component page element by its id. |
org.slf4j.Logger |
getEventLogger()
Returns a logger used to for logging event dispatch and event method invocation. |
String |
getId()
Returns the simple (or local) id of the component. |
Map<String,Binding> |
getInformalParameterBindings()
Constructs a map linking informal parameters to the corresponding bindings. |
Locale |
getLocale()
Returns the locale for the page containing this component. |
org.slf4j.Logger |
getLogger()
Returns the log instance associated with the component (which is based on the component or mixin's class name). |
Component |
getMixinByClassName(String mixinClassName)
Returns the mixin instance for the fully qualfied mixin class name. |
ComponentResources |
getMixinResources(String mixinId)
Returns the ComponentResources for a mixin attached to this component element. |
String |
getNestedId()
Return a string consisting the concatinated ids of all containing components, separated by periods. |
String |
getPageName()
Returns the logical name of the page containing this component. |
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 |
isLoaded()
Returns true if the component has finished loading. |
boolean |
isRendering()
Returns true if the component is currently rendering, false otherwise. |
ComponentPageElement |
newChild(String id,
String nestedId,
String completeId,
String elementName,
Instantiator instantiator,
Location location)
Creates a new child component of the invoked component. |
void |
render(MarkupWriter writer,
RenderQueue queue)
Pushes the SetupRender phase state onto the queue. |
String |
toString()
|
boolean |
triggerContextEvent(String eventType,
EventContext context,
ComponentEventCallback callback)
Triggers a component event. |
boolean |
triggerEvent(String eventType,
Object[] contextValues,
ComponentEventCallback callback)
A convienience for invoking ComponentResourcesCommon.triggerContextEvent(String, EventContext , ComponentEventCallback) . |
Methods inherited from class org.apache.tapestry5.ioc.BaseLocatable |
---|
getLocation |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.apache.tapestry5.ioc.Locatable |
---|
getLocation |
Constructor Detail |
---|
public ComponentPageElementImpl(Page page, Instantiator instantiator, ComponentPageElementResources elementResources, Request request, SymbolSource symbolSource)
Method Detail |
---|
public ComponentPageElement newChild(String id, String nestedId, String completeId, String elementName, Instantiator instantiator, Location location)
ComponentPageElement
newChild
in interface ComponentPageElement
id
- simple id of the new componentelementName
- name of the component's element in its container's templateinstantiator
- used to create a component instance, and access the component's modellocation
- location of the element within its container's template @return the new componentpublic void addMixin(String mixinId, Instantiator instantiator, String... order)
ComponentPageElement
addMixin
in interface ComponentPageElement
mixinId
- a unique id for the mixin, the last term of the mixin's class nameinstantiator
- used to instantiate an instance of the mixinorder
- Ordering strings used to determine the order of mixin execution.public void bindMixinParameter(String mixinId, String parameterName, Binding binding)
bindMixinParameter
in interface ComponentPageElement
mixinId
- id of previously added mixinparameterName
- simple (unqualified) name of parameterbinding
- binding for parameterpublic Binding getBinding(String parameterName)
InternalComponentResourcesCommon
getBinding
in interface InternalComponentResourcesCommon
parameterName
- name of component parameter
public void bindParameter(String parameterName, Binding binding)
InternalComponentResourcesCommon
bindParameter
in interface InternalComponentResourcesCommon
public void addToBody(RenderCommand element)
BodyPageElement
addToBody
in interface BodyPageElement
public void addToTemplate(RenderCommand element)
ComponentPageElement
addToTemplate
in interface ComponentPageElement
public void enqueueBeforeRenderBody(RenderQueue queue)
ComponentPageElement
enqueueBeforeRenderBody
in interface ComponentPageElement
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()
ComponentPageElement
getComponent
in interface ComponentPageElement
public InternalComponentResources getComponentResources()
ComponentPageElement
getComponentResources
in interface ComponentPageElement
public ComponentPageElement getContainerElement()
ComponentPageElement
getContainerElement
in interface ComponentPageElement
public Page getContainingPage()
ComponentPageElement
getContainingPage
in interface ComponentPageElement
public ComponentPageElement getEmbeddedElement(String embeddedId)
ComponentPageElement
getEmbeddedElement
in interface ComponentPageElement
embeddedId
- used to locate the element
public String getId()
ComponentResourcesCommon
getId
in interface ComponentResourcesCommon
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 name
public ComponentResources getMixinResources(String mixinId)
ComponentPageElement
ComponentResources
for a mixin attached to this component element. Mixin
ids are the simple names of the mixin class.
getMixinResources
in interface ComponentPageElement
mixinId
- the mixin id (case insensitive)
public String getNestedId()
ComponentResourcesCommon
getNestedId
in interface ComponentResourcesCommon
public boolean dispatchEvent(ComponentEvent event)
ComponentPageElement
Component.dispatchComponentEvent(ComponentEvent)
, returning true if any
handler was found.
dispatchEvent
in interface ComponentPageElement
event
- to be handled
public boolean isLoaded()
InternalComponentResourcesCommon
isLoaded
in interface InternalComponentResourcesCommon
PageLifecycleListener.containingPageDidLoad()
public boolean isRendering()
ComponentResourcesCommon
isRendering
in interface ComponentResourcesCommon
public final void render(MarkupWriter writer, RenderQueue queue)
render
in interface RenderCommand
public String toString()
toString
in class Object
public boolean triggerEvent(String eventType, Object[] contextValues, ComponentEventCallback callback)
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)contextValues
- Values that may be provided to the event handler method as method parameters, or null if no
context values are availablecallback
- 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 Locale getLocale()
ComponentResourcesCommon
getLocale
in interface ComponentResourcesCommon
ComponentResourcesCommon.getResourceSelector()
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 id)
ComponentResourcesCommon
getBlock
in interface ComponentResourcesCommon
id
- the id of the block (case insensitive)
ComponentResourcesCommon.findBlock(String)
public Block findBlock(String id)
ComponentResourcesCommon
ComponentResourcesCommon.getBlock(String)
, but returns null if the block is not found.
findBlock
in interface ComponentResourcesCommon
id
- the id of the block (case insensitive)
public void addBlock(String blockId, Block block)
ComponentPageElement
addBlock
in interface ComponentPageElement
ComponentResourcesCommon.getBlock(String)
public String getPageName()
ComponentResourcesCommon
getPageName
in interface ComponentResourcesCommon
public boolean hasBody()
ComponentResourcesCommon
hasBody
in interface ComponentResourcesCommon
public Block getBody()
ComponentResourcesCommon
getBody
in interface ComponentResourcesCommon
public Map<String,Binding> getInformalParameterBindings()
InternalComponentResourcesCommon
getInformalParameterBindings
in interface InternalComponentResourcesCommon
public org.slf4j.Logger getEventLogger()
ComponentPageElement
getEventLogger
in interface ComponentPageElement
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 encoded
public Link createActionLink(String eventType, boolean forForm, Object... context)
ComponentResourcesCommon
createActionLink
in interface ComponentResourcesCommon
eventType
- 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 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 encoded
public Link createPageLink(String pageName, boolean override, Object... context)
ComponentResourcesCommon
createPageLink
in interface ComponentResourcesCommon
pageName
- 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 ComponentResourcesCommon
pageClass
- 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
protected RenderPhaseEvent createRenderEvent(RenderQueue queue)
public ComponentResourceSelector getResourceSelector()
ComponentResourcesCommon
getResourceSelector
in interface ComponentResourcesCommon
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |