org.apache.tapestry
Class TapestryUtils

java.lang.Object
  extended by org.apache.tapestry.TapestryUtils

public class TapestryUtils
extends java.lang.Object

Constants and static methods.

Since:
4.0
Author:
Howard M. Lewis Ship

Field Summary
static java.lang.String FORM_ATTRIBUTE
           
static java.lang.String PAGE_RENDER_SUPPORT_ATTRIBUTE
           
 
Constructor Summary
TapestryUtils()
           
 
Method Summary
static java.lang.String buildClientElementReference(java.lang.String clientId)
          Converts a clientId into a client-side DOM reference; i.e.
static java.lang.String convertTapestryIdToNMToken(java.lang.String baseId)
          A Tapestry component id is a little more liberal than an XML NMTOKEN.
static java.lang.String enquote(java.lang.String input)
          Enquotes a string within single quotes, ready for insertion as part of a block of JavaScript.
static IComponent getComponent(IComponent container, java.lang.String componentId, java.lang.Class expectedType, org.apache.hivemind.Location location)
          Used by some generated code; obtains a component and ensures it is of the correct type.
static IForm getForm(IRequestCycle cycle, IComponent component)
          Gets the previously stored IForm object.
static PageRenderSupport getOptionalPageRenderSupport(IRequestCycle cycle)
          Returns the PageRenderSupport object if previously stored, or null otherwise.
static PageRenderSupport getPageRenderSupport(IRequestCycle cycle, IComponent component)
          Gets the previously stored PageRenderSupport object.
static void removeForm(IRequestCycle cycle)
           
static void removePageRenderSupport(IRequestCycle cycle)
           
static java.lang.String[] split(java.lang.String input)
          Splits a string using the default delimiter of ','.
static java.lang.String[] split(java.lang.String input, char delimiter)
          Splits a single string into an array of strings, using a specific delimiter character.
static void storeForm(IRequestCycle cycle, IForm form)
          Store the IForm instance using storeUniqueAttribute(IRequestCycle, String, Object).
static void storePageRenderSupport(IRequestCycle cycle, PageRenderSupport support)
          Stores the support object using storeUniqueAttribute(IRequestCycle, String, Object).
static void storeUniqueAttribute(IRequestCycle cycle, java.lang.String key, java.lang.Object object)
          Stores an attribute into the request cycle, verifying that no object with that key is already present.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PAGE_RENDER_SUPPORT_ATTRIBUTE

public static final java.lang.String PAGE_RENDER_SUPPORT_ATTRIBUTE
See Also:
Constant Field Values

FORM_ATTRIBUTE

public static final java.lang.String FORM_ATTRIBUTE
See Also:
Constant Field Values
Constructor Detail

TapestryUtils

public TapestryUtils()
Method Detail

storeUniqueAttribute

public static void storeUniqueAttribute(IRequestCycle cycle,
                                        java.lang.String key,
                                        java.lang.Object object)
Stores an attribute into the request cycle, verifying that no object with that key is already present.

Parameters:
cycle - the cycle to store the attribute into
key - the key to store the attribute as
object - the attribute value to store
Throws:
java.lang.IllegalStateException - if a non-null value has been stored into the cycle with the provided key.

storePageRenderSupport

public static void storePageRenderSupport(IRequestCycle cycle,
                                          PageRenderSupport support)
Stores the support object using storeUniqueAttribute(IRequestCycle, String, Object).


storeForm

public static void storeForm(IRequestCycle cycle,
                             IForm form)
Store the IForm instance using storeUniqueAttribute(IRequestCycle, String, Object).


getPageRenderSupport

public static PageRenderSupport getPageRenderSupport(IRequestCycle cycle,
                                                     IComponent component)
Gets the previously stored PageRenderSupport object.

Parameters:
cycle - the request cycle storing the support object
component - the component which requires the support (used to report exceptions)
Throws:
org.apache.hivemind.ApplicationRuntimeException - if no support object has been stored

getForm

public static IForm getForm(IRequestCycle cycle,
                            IComponent component)
Gets the previously stored IForm object.

Parameters:
cycle - the request cycle storing the support object
component - the component which requires the form (used to report exceptions)
Throws:
org.apache.hivemind.ApplicationRuntimeException - if no form object has been stored

removePageRenderSupport

public static void removePageRenderSupport(IRequestCycle cycle)

removeForm

public static void removeForm(IRequestCycle cycle)

getOptionalPageRenderSupport

public static PageRenderSupport getOptionalPageRenderSupport(IRequestCycle cycle)
Returns the PageRenderSupport object if previously stored, or null otherwise. This is used in the rare case that a component wishes to adjust its behavior based on whether the page render support services are avaiable (typically, adjust for whether enclosed by a Body component, or not).


split

public static java.lang.String[] split(java.lang.String input)
Splits a string using the default delimiter of ','.


split

public static java.lang.String[] split(java.lang.String input,
                                       char delimiter)
Splits a single string into an array of strings, using a specific delimiter character.


enquote

public static java.lang.String enquote(java.lang.String input)
Enquotes a string within single quotes, ready for insertion as part of a block of JavaScript. Single quotes and backslashes within the input string are properly escaped.


convertTapestryIdToNMToken

public static java.lang.String convertTapestryIdToNMToken(java.lang.String baseId)
A Tapestry component id is a little more liberal than an XML NMTOKEN. NMTOKEN must be [A-Za-z][A-Za-z0-9:_.-]*, but a component id might include a leading dollar sign (for an anonymous component with a fabricated id).


buildClientElementReference

public static java.lang.String buildClientElementReference(java.lang.String clientId)
Converts a clientId into a client-side DOM reference; i.e. document.getElementById('id').


getComponent

public static IComponent getComponent(IComponent container,
                                      java.lang.String componentId,
                                      java.lang.Class expectedType,
                                      org.apache.hivemind.Location location)
Used by some generated code; obtains a component and ensures it is of the correct type.