|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.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 ComponentPageElementid - 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 component
public void addMixin(String mixinId,
Instantiator instantiator,
String... order)
ComponentPageElement
addMixin in interface ComponentPageElementmixinId - 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 ComponentPageElementmixinId - id of previously added mixinparameterName - simple (unqualified) name of parameterbinding - binding for parameterpublic Binding getBinding(String parameterName)
InternalComponentResourcesCommon
getBinding in interface InternalComponentResourcesCommonparameterName - name of component parameter
public void bindParameter(String parameterName,
Binding binding)
InternalComponentResourcesCommon
bindParameter in interface InternalComponentResourcesCommonpublic void addToBody(RenderCommand element)
BodyPageElement
addToBody in interface BodyPageElementpublic void addToTemplate(RenderCommand element)
ComponentPageElement
addToTemplate in interface ComponentPageElementpublic void enqueueBeforeRenderBody(RenderQueue queue)
ComponentPageElement
enqueueBeforeRenderBody in interface ComponentPageElementpublic 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()
ComponentPageElement
getComponent in interface ComponentPageElementpublic InternalComponentResources getComponentResources()
ComponentPageElement
getComponentResources in interface ComponentPageElementpublic ComponentPageElement getContainerElement()
ComponentPageElement
getContainerElement in interface ComponentPageElementpublic Page getContainingPage()
ComponentPageElement
getContainingPage in interface ComponentPageElementpublic ComponentPageElement getEmbeddedElement(String embeddedId)
ComponentPageElement
getEmbeddedElement in interface ComponentPageElementembeddedId - used to locate the element
public String getId()
ComponentResourcesCommon
getId in interface ComponentResourcesCommonpublic 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 ComponentResources getMixinResources(String mixinId)
ComponentPageElementComponentResources for a mixin attached to this component element. Mixin
ids are the simple names of the mixin class.
getMixinResources in interface ComponentPageElementmixinId - the mixin id (case insensitive)
public String getNestedId()
ComponentResourcesCommon
getNestedId in interface ComponentResourcesCommonpublic boolean dispatchEvent(ComponentEvent event)
ComponentPageElementComponent.dispatchComponentEvent(ComponentEvent), returning true if any
handler was found.
dispatchEvent in interface ComponentPageElementevent - to be handled
public boolean isLoaded()
InternalComponentResourcesCommon
isLoaded in interface InternalComponentResourcesCommonPageLifecycleListener.containingPageDidLoad()public boolean isRendering()
ComponentResourcesCommon
isRendering in interface ComponentResourcesCommon
public final void render(MarkupWriter writer,
RenderQueue queue)
render in interface RenderCommandpublic String toString()
toString in class Object
public boolean triggerEvent(String eventType,
Object[] contextValues,
ComponentEventCallback callback)
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)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 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 Locale getLocale()
ComponentResourcesCommon
getLocale in interface ComponentResourcesCommonComponentResourcesCommon.getResourceSelector()public 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 id)
ComponentResourcesCommon
getBlock in interface ComponentResourcesCommonid - the id of the block (case insensitive)
ComponentResourcesCommon.findBlock(String)public Block findBlock(String id)
ComponentResourcesCommonComponentResourcesCommon.getBlock(String), but returns null if the block is not found.
findBlock in interface ComponentResourcesCommonid - the id of the block (case insensitive)
public void addBlock(String blockId,
Block block)
ComponentPageElement
addBlock in interface ComponentPageElementComponentResourcesCommon.getBlock(String)public String getPageName()
ComponentResourcesCommon
getPageName in interface ComponentResourcesCommonpublic boolean hasBody()
ComponentResourcesCommon
hasBody in interface ComponentResourcesCommonpublic Block getBody()
ComponentResourcesCommon
getBody in interface ComponentResourcesCommonpublic Map<String,Binding> getInformalParameterBindings()
InternalComponentResourcesCommon
getInformalParameterBindings in interface InternalComponentResourcesCommonpublic org.slf4j.Logger getEventLogger()
ComponentPageElement
getEventLogger in interface ComponentPageElement
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
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 | |||||||||