org.apache.turbine.services.ui

## Class TurbineUIService

- java.lang.Object
- - org.apache.turbine.services.BaseInitable
  - - org.apache.turbine.services.BaseService
    - - org.apache.turbine.services.TurbineBaseService
      - - org.apache.turbine.services.ui.TurbineUIService

- All Implemented Interfaces:
    Initable, Service, UIService

      public class TurbineUIService
      extends TurbineBaseService
      implements UIService

  The UI service provides for shared access to User Interface (skin) files, as well as the ability for non-default skin files to inherit properties from a default skin. Use TurbineUI to access skin properties from your screen classes and action code. UITool is provided as a pull tool for accessing skin properties from your templates.
  Version:
    $Id$
  Author:
    Jason van Zyl, James Coltman, Henning P. Schmiedehausen, Scott Eade, Thomas Vandahl
  See Also:
    `UIService`, `UITool`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `SKIN_PROPERTY_DEFAULT` Default skin name.

    - ### Fields inherited from class org.apache.turbine.services.BaseService

      `configuration, name, serviceBroker`

    - ### Fields inherited from class org.apache.turbine.services.BaseInitable

      `initableBroker, isInitialized`

    - ### Fields inherited from interface org.apache.turbine.services.ui.UIService

      `SERVICE_NAME`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TurbineUIService()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `get(String key)` Retrieve a skin property from the default skin for the webapp.
    `String` | `get(String skinName, String key)` Retrieve a skin property from the named skin.
    `String` | `getScript(String skinName, String filename)` Retrieve the URL for a given script that is part of a skin.
    `String` | `getScript(String skinName, String filename, ServerData serverData)` Retrieve the URL for a given script that is part of a skin.
    `String[]` | `getSkinNames()` Provide access to the list of available skin names.
    `String` | `getStylecss(String skinName)` Retrieve the URL for the style sheet that is part of a skin.
    `String` | `getStylecss(String skinName, ServerData serverData)` Retrieve the URL for the style sheet that is part of a skin.
    `String` | `getWebappSkinName()` Get the name of the default skin name for the web application from the TurbineResources.properties file.
    `String` | `image(String skinName, String imageId)` Retrieve the URL for an image that is part of a skin.
    `String` | `image(String skinName, String imageId, ServerData serverData)` Retrieve the URL for an image that is part of a skin.
    `void` | `init()` Initializes the service.
    `void` | `refresh()` Refresh the service by clearing all skins.
    `void` | `refresh(String skinName)` Refresh a particular skin by clearing it.
    `void` | `shutdown()` Returns to uninitialized state.

    - ### Methods inherited from class org.apache.turbine.services.TurbineBaseService

      `init, init`

    - ### Methods inherited from class org.apache.turbine.services.BaseService

      `getConfiguration, getName, getProperties, getServiceBroker, setName, setServiceBroker`

    - ### Methods inherited from class org.apache.turbine.services.BaseInitable

      `getInit, getInitableBroker, setInit, setInitableBroker`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.apache.turbine.services.Service

      `getConfiguration, getName, getProperties, setName, setServiceBroker`

    - ### Methods inherited from interface org.apache.turbine.services.Initable

      `getInit, init, setInitableBroker`

- - ### Field Detail

    - #### SKIN_PROPERTY_DEFAULT

          public static final String SKIN_PROPERTY_DEFAULT

      Default skin name. This name refers to a directory in the WEBAPP/resources/ui/skins directory. There is a file called skin.props which contains the name/value pairs to be made available via the skin.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### TurbineUIService

          public TurbineUIService()

  - ### Method Detail

    - #### refresh

          public void refresh()

      Refresh the service by clearing all skins.
      Specified by:
        `refresh` in interface `UIService`

    - #### refresh

          public void refresh(String skinName)

      Refresh a particular skin by clearing it.
      Specified by:
        `refresh` in interface `UIService`
      Parameters:
        `skinName` - the name of the skin to clear.

    - #### get

          public String get(String skinName,
                   String key)

      Retrieve a skin property from the named skin. If the property is not defined in the named skin the value for the default skin will be provided. If the named skin does not exist then the skin configured for the webapp will be used. If the webapp skin does not exist the default skin will be used. If the default skin does not exist then `null` will be returned.
      Specified by:
        `get` in interface `UIService`
      Parameters:
        `skinName` - the name of the skin to retrieve the property from.
        `key` - the key to retrieve from the skin.
      Returns:
        the value of the property for the named skin (defaulting to the default skin), the webapp skin, the default skin or `null`, depending on whether or not the property or skins exist.

    - #### get

          public String get(String key)

      Retrieve a skin property from the default skin for the webapp. If the property is not defined in the webapp skin the value for the default skin will be provided. If the webapp skin does not exist the default skin will be used. If the default skin does not exist then `null` will be returned.
      Specified by:
        `get` in interface `UIService`
      Parameters:
        `key` - the key to retrieve.
      Returns:
        the value of the property for the webapp skin (defaulting to the default skin), the default skin or `null`, depending on whether or not the property or skins exist.

    - #### getSkinNames

          public String[] getSkinNames()

      Provide access to the list of available skin names.
      Specified by:
        `getSkinNames` in interface `UIService`
      Returns:
        the available skin names.

    - #### getWebappSkinName

          public String getWebappSkinName()

      Get the name of the default skin name for the web application from the TurbineResources.properties file. If the property is not present the name of the default skin will be returned. Note that the web application skin name may be something other than default, in which case its properties will default to the skin with the name "default".
      Specified by:
        `getWebappSkinName` in interface `UIService`
      Returns:
        the name of the default skin for the web application.

    - #### image

          public String image(String skinName,
                     String imageId,
                     ServerData serverData)

      Retrieve the URL for an image that is part of a skin. The images are stored in the WEBAPP/resources/ui/skins/[SKIN]/images directory.

      Use this if for some reason your server name, server scheme, or server port change on a per request basis. I'm not sure if this would happen in a load balanced situation. I think in most cases the image(String image) method would probably be enough, but I'm not absolutely positive.

      Specified by:
        `image` in interface `UIService`
      Parameters:
        `skinName` - the name of the skin to retrieve the image from.
        `imageId` - the id of the image whose URL will be generated.
        `serverData` - the serverData to use as the basis for the URL.
      Returns:
        the image URL

    - #### image

          public String image(String skinName,
                     String imageId)

      Retrieve the URL for an image that is part of a skin. The images are stored in the WEBAPP/resources/ui/skins/[SKIN]/images directory.
      Specified by:
        `image` in interface `UIService`
      Parameters:
        `skinName` - the name of the skin to retrieve the image from.
        `imageId` - the id of the image whose URL will be generated.
      Returns:
        the image URL

    - #### getStylecss

          public String getStylecss(String skinName,
                           ServerData serverData)

      Retrieve the URL for the style sheet that is part of a skin. The style is stored in the WEBAPP/resources/ui/skins/[SKIN] directory with the filename skin.css

      Use this if for some reason your server name, server scheme, or server port change on a per request basis. I'm not sure if this would happen in a load balanced situation. I think in most cases the style() method would probably be enough, but I'm not absolutely positive.

      Specified by:
        `getStylecss` in interface `UIService`
      Parameters:
        `skinName` - the name of the skin to retrieve the style sheet from.
        `serverData` - the serverData to use as the basis for the URL.
      Returns:
        the CSS URL

    - #### getStylecss

          public String getStylecss(String skinName)

      Retrieve the URL for the style sheet that is part of a skin. The style is stored in the WEBAPP/resources/ui/skins/[SKIN] directory with the filename skin.css
      Specified by:
        `getStylecss` in interface `UIService`
      Parameters:
        `skinName` - the name of the skin to retrieve the style sheet from.
      Returns:
        the CSS URL

    - #### getScript

          public String getScript(String skinName,
                         String filename,
                         ServerData serverData)

      Retrieve the URL for a given script that is part of a skin. The script is stored in the WEBAPP/resources/ui/skins/[SKIN] directory.

      Use this if for some reason your server name, server scheme, or server port change on a per request basis. I'm not sure if this would happen in a load balanced situation. I think in most cases the style() method would probably be enough, but I'm not absolutely positive.

      Specified by:
        `getScript` in interface `UIService`
      Parameters:
        `skinName` - the name of the skin to retrieve the image from.
        `filename` - the name of the script file.
        `serverData` - the serverData to use as the basis for the URL.
      Returns:
        the script URL

    - #### getScript

          public String getScript(String skinName,
                         String filename)

      Retrieve the URL for a given script that is part of a skin. The script is stored in the WEBAPP/resources/ui/skins/[SKIN] directory.
      Specified by:
        `getScript` in interface `UIService`
      Parameters:
        `skinName` - the name of the skin to retrieve the image from.
        `filename` - the name of the script file.
      Returns:
        the script URL

    - #### init

          public void init()
                    throws InitializationException

      Initializes the service.
      Specified by:
        `init` in interface `Initable`
      Overrides:
        `init` in class `TurbineBaseService`
      Throws:
        `InitializationException` - if initialization of this class was not successful.

    - #### shutdown

          public void shutdown()

      Returns to uninitialized state.
      Specified by:
        `shutdown` in interface `Initable`
      Overrides:
        `shutdown` in class `TurbineBaseService`

Copyright © 2000–2018 The Apache Software Foundation. All rights reserved.