org.apache.tapestry
Class Tapestry

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

public final class Tapestry
extends Object

A placeholder for a number of (static) methods that don't belong elsewhere, as well as a global location for static constants.

Since:
1.0.1
Author:
Howard Lewis Ship

Field Summary
static String ABSTRACTPAGE_DETACH_METHOD_ID
          Method id used to check that IPage.detach() is invoked.
static String ABSTRACTPAGE_VALIDATE_METHOD_ID
          Method id used to check that IPage.validate(IRequestCycle) is invoked.
static String ASSET_SERVICE
          The name ("asset") of a service used to access internal assets.
static String DIRECT_EVENT_SERVICE
          Almost identical to the direct service, except specifically for handling browser level events.
static String DIRECT_SERVICE
          The name ("direct") of a service that allows stateless behavior for an DirectLink component.
static String EXTERNAL_SERVICE
          The name ("external") of a service that a allows IExternalPage to be selected.
static String HOME_SERVICE
          The name ("home") of a service that jumps to the home page.
static String LINK_COMPONENT_ATTRIBUTE_NAME
          The name of an IRequestCycle attribute in which the currently rendering ILinkComponent is stored.
static String MULTIPART_DECODER_EXTENSION_NAME
          Name of optional application extension for the multipart decoder used by the application.
static String OGNL_TYPE_CONVERTER
          Class name of an TypeConverterimplementing class to use as a type converter for ExpressionBinding.
static String PAGE_SERVICE
          The name ("page") of a service that allows a new page to be selected.
static String PARAMETER_PROPERTY_NAME_SUFFIX
          Suffix appended to a parameter name to form the name of a property that stores the binding for the parameter.
static String REQUEST_DECODER_EXTENSION_NAME
          Key used to obtain an extension from the application specification.
static String RESET_SERVICE
          The name ("reset") of a service used to clear cached template and specification data and remove all pooled pages.
static String RESTART_SERVICE
          The name ("restart") of a service that invalidates the session and restarts the application.
static String SIMPLE_PROPERTY_NAME_PATTERN
          Regular expression defining a simple property name.
static String TEMPLATE_EXTENSION_PROPERTY
          Property name used to get the extension used for templates.
static String VERSION
          The version of the framework; this is updated for major releases.
 
Method Summary
static void addMethodInvocation(Object methodId)
          Adds a method invocation to the list of invocations.
static void checkMethodInvocation(Object methodId, String methodName, Object object)
          Checks to see if a particular method has been invoked.
static void clearMethodInvocations()
          Clears the list of method invocations.
static void close(InputStream stream)
          Closes the stream (if not null), ignoring any IOExceptionthrown.
static Map convertArrayToMap(Object[] array)
          Converts an even-sized array of objects back into a Map.
static Object[] convertMapToArray(Map map)
          Converts a Map to an even-sized array of key/value pairs.
static void copyInformalBindings(IComponent source, IComponent destination)
          Copys all informal bindingsfrom a source component to the destination component.
static org.apache.hivemind.ApplicationRuntimeException createNoSuchComponentException(IComponent component, String id, org.apache.hivemind.Location location)
           
static BindingException createNullBindingException(IBinding binding)
          Creates an exception indicating the binding value is null.
static org.apache.hivemind.ApplicationRuntimeException createRenderOnlyPropertyException(IComponent component, String propertyName)
           
static BindingException createRequiredParameterException(IComponent component, String parameterName)
           
static void fireObservedChange(IComponent component, String propertyName, Object newValue)
          Method used by pages and components to send notifications about property changes.
static String format(String key, Object arg)
          Convienience method for invoking format(String, Object[]).
static String format(String key, Object[] args)
          Gets a string from the TapestryStrings resource bundle.
static String format(String key, Object arg1, Object arg2)
          Convienience method for invoking format(String, Object[]).
static String format(String key, Object arg1, Object arg2, Object arg3)
          Convienience method for invoking format(String, Object[]).
static Locale getLocale(String s)
          Gets the Localefor the given string, which is the result of Locale.toString().
static String getMessage(String key)
          Convienience method for invoking format(String, Object[]).
static boolean isEmpty(Collection c)
          Returns true if the Collection is null or empty.
static boolean isEmpty(Map map)
          Returns true if the Map is null or empty.
static int size(Collection c)
          Returns the size of a collection, or zero if the collection is null.
static int size(Object[] array)
          Returns the length of the array, or 0 if the array is null.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DIRECT_SERVICE

public static final String DIRECT_SERVICE
The name ("direct") of a service that allows stateless behavior for an DirectLink component.

This service rolls back the state of the page but doesn't rewind the the dynamic state of the page the was the action service does, which is more efficient but less powerful.

An array of String parameters may be included with the service URL; these will be made available to the DirectLink component's listener.

See Also:
Constant Field Values

DIRECT_EVENT_SERVICE

public static final String DIRECT_EVENT_SERVICE
Almost identical to the direct service, except specifically for handling browser level events.

Since:
4.1
See Also:
Constant Field Values

EXTERNAL_SERVICE

public static final String EXTERNAL_SERVICE
The name ("external") of a service that a allows IExternalPage to be selected. Associated with a ExternalLink component.

This service enables IExternalPages to be accessed via a URL. External pages may be booked marked using their URL for future reference.

An array of Object parameters may be included with the service URL; these will be passed to the IExternalPage.activateExternalPage(Object[], IRequestCycle) method.

See Also:
Constant Field Values

PAGE_SERVICE

public static final String PAGE_SERVICE
The name ("page") of a service that allows a new page to be selected. Associated with a PageLink component.

The service requires a single parameter: the name of the target page.

See Also:
Constant Field Values

HOME_SERVICE

public static final String HOME_SERVICE
The name ("home") of a service that jumps to the home page. A stand-in for when no service is provided, which is typically the entrypoint to the application.

See Also:
Constant Field Values

RESTART_SERVICE

public static final String RESTART_SERVICE
The name ("restart") of a service that invalidates the session and restarts the application. Typically used just to recover from an exception.

See Also:
Constant Field Values

ASSET_SERVICE

public static final String ASSET_SERVICE
The name ("asset") of a service used to access internal assets.

See Also:
Constant Field Values

RESET_SERVICE

public static final String RESET_SERVICE
The name ("reset") of a service used to clear cached template and specification data and remove all pooled pages. This is only used when debugging as a quick way to clear the out cached data, to allow updated versions of specifications and templates to be loaded (without stopping and restarting the servlet container).

This service is only available if the Java system property org.apache.tapestry.enable-reset-service is set to true.

See Also:
Constant Field Values

TEMPLATE_EXTENSION_PROPERTY

public static final String TEMPLATE_EXTENSION_PROPERTY
Property name used to get the extension used for templates. This may be set in the page or component specification, or in the page (or component's) immediate container (library or application specification). Unlike most properties, value isn't inherited all the way up the chain. The default template extension is "html".

Since:
3.0
See Also:
Constant Field Values

LINK_COMPONENT_ATTRIBUTE_NAME

public static final String LINK_COMPONENT_ATTRIBUTE_NAME
The name of an IRequestCycle attribute in which the currently rendering ILinkComponent is stored. Link components do not nest.

See Also:
Constant Field Values

PARAMETER_PROPERTY_NAME_SUFFIX

public static final String PARAMETER_PROPERTY_NAME_SUFFIX
Suffix appended to a parameter name to form the name of a property that stores the binding for the parameter.

Since:
3.0
See Also:
Constant Field Values

REQUEST_DECODER_EXTENSION_NAME

public static final String REQUEST_DECODER_EXTENSION_NAME
Key used to obtain an extension from the application specification. The extension, if it exists, implements IRequestDecoder.

Since:
2.2
See Also:
Constant Field Values

MULTIPART_DECODER_EXTENSION_NAME

public static final String MULTIPART_DECODER_EXTENSION_NAME
Name of optional application extension for the multipart decoder used by the application. The extension must implement IMultipartDecoder (and is generally a configured instance of IMultipartDecoder).

Since:
3.0
See Also:
Constant Field Values

ABSTRACTPAGE_VALIDATE_METHOD_ID

public static final String ABSTRACTPAGE_VALIDATE_METHOD_ID
Method id used to check that IPage.validate(IRequestCycle) is invoked.

Since:
3.0
See Also:
checkMethodInvocation(Object, String, Object), Constant Field Values

ABSTRACTPAGE_DETACH_METHOD_ID

public static final String ABSTRACTPAGE_DETACH_METHOD_ID
Method id used to check that IPage.detach() is invoked.

Since:
3.0
See Also:
checkMethodInvocation(Object, String, Object), Constant Field Values

SIMPLE_PROPERTY_NAME_PATTERN

public static final String SIMPLE_PROPERTY_NAME_PATTERN
Regular expression defining a simple property name. Used by several different parsers. Simple property names match Java variable names; a leading letter (or underscore), followed by letters, numbers and underscores.

Since:
3.0
See Also:
Constant Field Values

OGNL_TYPE_CONVERTER

public static final String OGNL_TYPE_CONVERTER
Class name of an TypeConverterimplementing class to use as a type converter for ExpressionBinding.

See Also:
Constant Field Values

VERSION

public static final String VERSION
The version of the framework; this is updated for major releases.

Method Detail

copyInformalBindings

public static void copyInformalBindings(IComponent source,
                                        IComponent destination)
Copys all informal bindingsfrom a source component to the destination component. Informal bindings are bindings for informal parameters. This will overwrite parameters (formal or informal) in the destination component if there is a naming conflict.


getLocale

public static Locale getLocale(String s)
Gets the Localefor the given string, which is the result of Locale.toString(). If no such locale is already registered, a new instance is created, registered and returned.


close

public static void close(InputStream stream)
Closes the stream (if not null), ignoring any IOExceptionthrown.

Since:
1.0.2

format

public static String format(String key,
                            Object[] args)
Gets a string from the TapestryStrings resource bundle. The string in the bundle is treated as a pattern for MessageFormat.format(java.lang.String, java.lang.Object[]).

Since:
1.0.8

getMessage

public static String getMessage(String key)
Convienience method for invoking format(String, Object[]).

Since:
3.0

format

public static String format(String key,
                            Object arg)
Convienience method for invoking format(String, Object[]).

Since:
3.0

format

public static String format(String key,
                            Object arg1,
                            Object arg2)
Convienience method for invoking format(String, Object[]).

Since:
3.0

format

public static String format(String key,
                            Object arg1,
                            Object arg2,
                            Object arg3)
Convienience method for invoking format(String, Object[]).

Since:
3.0

size

public static int size(Collection c)
Returns the size of a collection, or zero if the collection is null.

Since:
2.2

size

public static int size(Object[] array)
Returns the length of the array, or 0 if the array is null.

Since:
2.2

isEmpty

public static boolean isEmpty(Map map)
Returns true if the Map is null or empty.

Since:
3.0

isEmpty

public static boolean isEmpty(Collection c)
Returns true if the Collection is null or empty.

Since:
3.0

convertMapToArray

public static Object[] convertMapToArray(Map map)
Converts a Map to an even-sized array of key/value pairs. This may be useful when using a Map as service parameters (with DirectLink. Assuming the keys and values are simple objects (String, Boolean, Integer, etc.), then the representation as an array will encode more efficiently (via DataSqueezerImpl than serializing the Map and its contents.

Returns:
the array of keys and values, or null if the input Map is null or empty
Since:
2.2

convertArrayToMap

public static Map convertArrayToMap(Object[] array)
Converts an even-sized array of objects back into a Map.

Returns:
a Map, or null if the array is null or empty
Since:
2.2
See Also:
convertMapToArray(Map)

createNullBindingException

public static BindingException createNullBindingException(IBinding binding)
Creates an exception indicating the binding value is null.

Since:
3.0

createNoSuchComponentException

public static org.apache.hivemind.ApplicationRuntimeException createNoSuchComponentException(IComponent component,
                                                                                             String id,
                                                                                             org.apache.hivemind.Location location)
Since:
3.0 *

createRequiredParameterException

public static BindingException createRequiredParameterException(IComponent component,
                                                                String parameterName)
Since:
3.0 *

createRenderOnlyPropertyException

public static org.apache.hivemind.ApplicationRuntimeException createRenderOnlyPropertyException(IComponent component,
                                                                                                String propertyName)
Since:
3.0 *

clearMethodInvocations

public static void clearMethodInvocations()
Clears the list of method invocations.

Since:
3.0
See Also:
checkMethodInvocation(Object, String, Object)

addMethodInvocation

public static void addMethodInvocation(Object methodId)
Adds a method invocation to the list of invocations. This is done in a super-class implementations.

Since:
3.0
See Also:
checkMethodInvocation(Object, String, Object)

checkMethodInvocation

public static void checkMethodInvocation(Object methodId,
                                         String methodName,
                                         Object object)
Checks to see if a particular method has been invoked. The method is identified by a methodId (usually a String). The methodName and object are used to create an error message.

The caller should invoke clearMethodInvocations(), then invoke a method on the object. The super-class implementation should invoke addMethodInvocation(Object) to indicate that it was, in fact, invoked. The caller then invokes this method to validate that the super-class implementation was invoked.

The list of method invocations is stored in a ThreadLocal variable.

Since:
3.0

fireObservedChange

public static void fireObservedChange(IComponent component,
                                      String propertyName,
                                      Object newValue)
Method used by pages and components to send notifications about property changes.

Parameters:
component - the component containing the property
propertyName - the name of the property which changed
newValue - the new value for the property
Since:
3.0


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