Package org.apache.tapestry5.internal.structure

## Class ComponentPageElementResourcesImpl

- java.lang.Object
- - org.apache.tapestry5.internal.structure.ComponentPageElementResourcesImpl

- All Implemented Interfaces:
    `ComponentPageElementResources`, `OperationTracker`, `ContextValueEncoder`

      public class ComponentPageElementResourcesImpl
      extends java.lang.Object
      implements ComponentPageElementResources

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface org.apache.tapestry5.ioc.OperationTracker

      `OperationTracker.NonLoggableException`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `ComponentPageElementResourcesImpl​(ComponentResourceSelector selector, ComponentMessagesSource componentMessagesSource, TypeCoercer typeCoercer, ComponentClassCache componentClassCache, ContextValueEncoder contextValueEncoder, LinkSource linkSource, RequestPageCache requestPageCache, ComponentClassResolver componentClassResolver, LoggerSource loggerSource, OperationTracker tracker, PerthreadManager perThreadManager, boolean productionMode, boolean componentTracingEnabled, RequestGlobals requestGlobals)` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `<S,​T> T` | `coerce​(S input, java.lang.Class<T> targetType)` | Performs a coercion from an input type to a desired output type.
    `Link` | `createComponentEventLink​(ComponentResources resources, java.lang.String eventType, boolean forForm, java.lang.Object... context)` | Creates a link on behalf of a component.
    `Link` | `createPageRenderLink​(java.lang.Class pageClass, boolean override, java.lang.Object... context)` | Creates a page render request link to render a specific page.
    `Link` | `createPageRenderLink​(java.lang.String pageName, boolean override, java.lang.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​(java.lang.String description, Invokable<T> operation)` | As with `OperationTracker.run(String, Runnable)`, but the operation may return a value.
    `boolean` | `isRenderTracingEnabled()` | Returns true if component element tracing is enabled.
    `<T> T` | `perform​(java.lang.String description, IOOperation<T> operation)` | As with `OperationTracker.invoke(String, Invokable)`, but the operation may throw an `IOException`.
    `void` | `run​(java.lang.String description, java.lang.Runnable operation)` | Executes the operation.
    `java.lang.Class` | `toClass​(java.lang.String className)` | Gets the Class instance for then give name.
    `java.lang.String` | `toClient​(java.lang.Object value)` | Converts a context value into a client-side string (that will ultimately be encoded into a URL).
    `<T> T` | `toValue​(java.lang.Class<T> requiredType, java.lang.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,
                                                   boolean productionMode,
                                                   boolean componentTracingEnabled,
                                                   RequestGlobals requestGlobals)

  - ### 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,
                                      java.lang.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 java.lang.Class toClass​(java.lang.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,
                                               java.lang.String eventType,
                                               boolean forForm,
                                               java.lang.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​(java.lang.String pageName,
                                           boolean override,
                                           java.lang.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​(java.lang.Class pageClass,
                                           boolean override,
                                           java.lang.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 java.lang.String toClient​(java.lang.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​(java.lang.Class<T> requiredType,
                               java.lang.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​(java.lang.String description,
                              Invokable<T> operation)

      Description copied from interface: `OperationTracker`
      As with `OperationTracker.run(String, Runnable)`, but the operation may return a value.
      Specified by:
        `invoke` in interface `OperationTracker`
      Parameters:
        `description` - used if there is an exception
        `operation` - to invoke
      Returns:
        result of operation

    - #### perform

          public <T> T perform​(java.lang.String description,
                               IOOperation<T> operation)
                        throws java.io.IOException

      Description copied from interface: `OperationTracker`
      As with `OperationTracker.invoke(String, Invokable)`, but the operation may throw an `IOException`.
      Specified by:
        `perform` in interface `OperationTracker`
      Parameters:
        `description` - used if there is an exception (outside of IOException)
        `operation` - to perform
      Returns:
        result of operation
      Throws:
        `java.io.IOException`

    - #### run

          public void run​(java.lang.String description,
                          java.lang.Runnable operation)

      Description copied from interface: `OperationTracker`
      Executes the operation. If the operation throws a `RuntimeException` it will be logged and rethrown wrapped as a `OperationException`.
      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`

    - #### isRenderTracingEnabled

          public boolean isRenderTracingEnabled()

      Description copied from interface: `ComponentPageElementResources`
      Returns true if component element tracing is enabled. When enabled, rendering of the component produces additional comments to identify what component and stage is rendering.
      Specified by:
        `isRenderTracingEnabled` in interface `ComponentPageElementResources`