org.apache.tapestry
Class TapestryUtils

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

public final class TapestryUtils
extends Object

Constants and static methods.

Since:
4.0
Author:
Howard M. Lewis Ship

Field Summary
static String FIELD_PRERENDER
           
static String FORM_ATTRIBUTE
           
static String PAGE_RENDER_SUPPORT_ATTRIBUTE
           
 
Method Summary
static String buildClientElementReference(String clientId)
          Converts a clientId into a client-side DOM reference; i.e.
static String capitalize(String input)
          Capitalize the first letter of the input if at least 1 character.
static String convertTapestryIdToNMToken(String baseId)
          A Tapestry component id is a little more liberal than an XML NMTOKEN.
static String enquote(String input)
          Enquotes a string within single quotes, ready for insertion as part of a block of JavaScript.
static IComponent getComponent(IComponent container, String componentId, 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 void removePrerender(IRequestCycle cycle)
           
static String[] split(String input)
          Splits a string using the default delimiter of ','.
static String[] split(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 storePrerender(IRequestCycle cycle, IComponent component)
          Stores the IComponent into the cycle by FormSupport before doing a field prerender.
static void storeUniqueAttribute(IRequestCycle cycle, String key, 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 String PAGE_RENDER_SUPPORT_ATTRIBUTE
See Also:
Constant Field Values

FORM_ATTRIBUTE

public static final String FORM_ATTRIBUTE
See Also:
Constant Field Values

FIELD_PRERENDER

public static final String FIELD_PRERENDER
See Also:
Constant Field Values
Method Detail

storeUniqueAttribute

public static void storeUniqueAttribute(IRequestCycle cycle,
                                        String key,
                                        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:
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).


storePrerender

public static void storePrerender(IRequestCycle cycle,
                                  IComponent component)
Stores the IComponent into the cycle by FormSupport before doing a field prerender.

Parameters:
cycle -
component -

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)

removePrerender

public static void removePrerender(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 available (typically, adjust for whether enclosed by a Body component, or not).


split

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


split

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


capitalize

public static String capitalize(String input)
Capitalize the first letter of the input if at least 1 character.


enquote

public static String enquote(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 String convertTapestryIdToNMToken(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 String buildClientElementReference(String clientId)
Converts a clientId into a client-side DOM reference; i.e. document.getElementById('id').


getComponent

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



Copyright © 2006-2008 Apache Software Foundation. All Rights Reserved.