org.apache.tapestry5.internal.structure
Class ComponentPageElementResourcesImpl

java.lang.Object
  extended by org.apache.tapestry5.internal.structure.ComponentPageElementResourcesImpl
All Implemented Interfaces:
ComponentPageElementResources, OperationTracker, ContextValueEncoder

public class ComponentPageElementResourcesImpl
extends Object
implements ComponentPageElementResources


Constructor Summary
ComponentPageElementResourcesImpl(ComponentResourceSelector selector, ComponentMessagesSource componentMessagesSource, TypeCoercer typeCoercer, ComponentClassCache componentClassCache, ContextValueEncoder contextValueEncoder, LinkSource linkSource, RequestPageCache requestPageCache, ComponentClassResolver componentClassResolver, LoggerSource loggerSource, OperationTracker tracker, PerthreadManager perThreadManager)
           
 
Method Summary
<S,T> T
coerce(S input, Class<T> targetType)
          Performs a coercion from an input type to a desired output type.
 Link createComponentEventLink(ComponentResources resources, String eventType, boolean forForm, Object... context)
          Creates a link on behalf of a component.
 Link createPageRenderLink(Class pageClass, boolean override, Object... context)
          Creates a page render request link to render a specific page.
 Link createPageRenderLink(String pageName, boolean override, Object... context)
          Creates a page render request link to render a specific page.
<T> PerThreadValue<T>
createPerThreadValue()
          Wrapper around PerthreadManager.createValue().
 org.slf4j.Logger getEventLogger(org.slf4j.Logger componentLogger)
          Returns the event logger for the provided component logger.
 Messages getMessages(ComponentModel componentModel)
          Used to obtain a Messages instance for a particular component.
 ComponentResourceSelector getSelector()
          Returns the selector associated with this resources.
<T> T
invoke(String description, Invokable<T> operation)
          Executes the operation, returning its value.
 void run(String description, Runnable operation)
          Executes the operation.
 Class toClass(String className)
          Gets the Class instance for then give name.
 String toClient(Object value)
          Converts a context value into a client-side string (that will ultimately be encoded into a URL).
<T> T
toValue(Class<T> requiredType, String clientValue)
          Converts a client value back into a server-side object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ComponentPageElementResourcesImpl

public ComponentPageElementResourcesImpl(ComponentResourceSelector selector,
                                         ComponentMessagesSource componentMessagesSource,
                                         TypeCoercer typeCoercer,
                                         ComponentClassCache componentClassCache,
                                         ContextValueEncoder contextValueEncoder,
                                         LinkSource linkSource,
                                         RequestPageCache requestPageCache,
                                         ComponentClassResolver componentClassResolver,
                                         LoggerSource loggerSource,
                                         OperationTracker tracker,
                                         PerthreadManager perThreadManager)
Method Detail

getSelector

public ComponentResourceSelector getSelector()
Description copied from interface: ComponentPageElementResources
Returns the selector associated with this resources.

Specified by:
getSelector in interface ComponentPageElementResources

getMessages

public Messages getMessages(ComponentModel componentModel)
Description copied from interface: ComponentPageElementResources
Used to obtain a Messages instance for a particular component. If the component extends from another component, then its localized properties will merge with its parent's properties (with the subclass overriding the super class on any conflicts).

Specified by:
getMessages in interface ComponentPageElementResources
Returns:
the message catalog for the component, in the indicated locale
See Also:
ComponentMessagesSource

coerce

public <S,T> T coerce(S input,
                      Class<T> targetType)
Description copied from interface: ComponentPageElementResources
Performs a coercion from an input type to a desired output type. When the target type is a primitive, the actual conversion will be to the equivalent wrapper type. In some cases, the TypeCoercer will need to search for an appropriate coercion, and may even combine existing coercions to form new ones; in those cases, the results of the search are cached.

Specified by:
coerce in interface ComponentPageElementResources
Type Parameters:
S - source type (input)
T - target type (output)
targetType - defines the target type
Returns:
the coerced value
See Also:
TypeCoercer

toClass

public Class toClass(String className)
Description copied from interface: ComponentPageElementResources
Gets the Class instance for then give name.

Specified by:
toClass in interface ComponentPageElementResources
Parameters:
className - fully qualified class name
Returns:
the class instance
See Also:
ComponentClassCache

createComponentEventLink

public Link createComponentEventLink(ComponentResources resources,
                                     String eventType,
                                     boolean forForm,
                                     Object... context)
Description copied from interface: ComponentPageElementResources
Creates a link on behalf of a component.

Specified by:
createComponentEventLink in interface ComponentPageElementResources
Parameters:
resources - resources for the component
eventType - type of event to create
forForm - true if generating for a form submission
context - additional event context associated with the link
Returns:
the link

createPageRenderLink

public Link createPageRenderLink(String pageName,
                                 boolean override,
                                 Object... context)
Description copied from interface: ComponentPageElementResources
Creates a page render request link to render a specific page.

Specified by:
createPageRenderLink in interface ComponentPageElementResources
Parameters:
pageName - the logical name of the page to link to
override - 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
Returns:
link for a render request to the targetted page

createPageRenderLink

public Link createPageRenderLink(Class pageClass,
                                 boolean override,
                                 Object... context)
Description copied from interface: ComponentPageElementResources
Creates a page render request link to render a specific page. Using a page class, rather than a page name, is more refactoring safe (in the even the page is renamed or moved).

Specified by:
createPageRenderLink in interface ComponentPageElementResources
Parameters:
pageClass - identifies the page to link to
override - 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
Returns:
link for a render request to the targetted page

getEventLogger

public org.slf4j.Logger getEventLogger(org.slf4j.Logger componentLogger)
Description copied from interface: ComponentPageElementResources
Returns the event logger for the provided component logger. The event logger is based on the component logger's name (which matches the component class name) with a "tapestry..events." prefix.

Specified by:
getEventLogger in interface ComponentPageElementResources
Parameters:
componentLogger - provides base name for logger
Returns:
the logger

toClient

public String toClient(Object value)
Description copied from interface: ContextValueEncoder
Converts a context value into a client-side string (that will ultimately be encoded into a URL).

Specified by:
toClient in interface ContextValueEncoder
Parameters:
value - to convert (may not be null)
Returns:
string representation of the value
See Also:
ValueEncoder.toClient(Object)

toValue

public <T> T toValue(Class<T> requiredType,
                     String clientValue)
Description copied from interface: ContextValueEncoder
Converts a client value back into a server-side object.

Specified by:
toValue in interface ContextValueEncoder
Parameters:
requiredType - required type to convert the string to
clientValue - value obtained from context passed from client
Returns:
the client value converted or coerced into a server value
See Also:
ValueEncoder.toValue(String)

invoke

public <T> T invoke(String description,
                    Invokable<T> operation)
Description copied from interface: OperationTracker
Executes the operation, returning its value.

Specified by:
invoke in interface OperationTracker
Parameters:
description - used if there is an exception
operation - to invoke
Returns:
result of operation

run

public void run(String description,
                Runnable operation)
Description copied from interface: OperationTracker
Executes the operation.

Specified by:
run in interface OperationTracker
Parameters:
description - used if there is an exception
operation - to execute

createPerThreadValue

public <T> PerThreadValue<T> createPerThreadValue()
Description copied from interface: ComponentPageElementResources
Wrapper around PerthreadManager.createValue().

Specified by:
createPerThreadValue in interface ComponentPageElementResources


Copyright © 2003-2012 The Apache Software Foundation.