javawebparts.ajaxparts.taglib
Class AjaxUtils

java.lang.Object
  |
  +--javawebparts.ajaxparts.taglib.AjaxUtils

public final class AjaxUtils
extends java.lang.Object

This class contains utility functions used throughout the taglib.

Author:
Frank W. Zammetti

Field Summary
private static org.apache.commons.logging.Log log
          Log instance.
 
Constructor Summary
private AjaxUtils()
          This is a utility class, so we want a private noarg constructor so instances cannot be created.
 
Method Summary
static java.lang.String elementRefFromAjaxRef(java.lang.String ajaxRef)
          This method takes an ajaxRef (which is assumed to be in the correct format) and returns just the element's ajaxRef.
static java.lang.String getResource(java.lang.String inResName)
          This method returns a String from a resource loaded from the classpath, including within a JAR file.
static java.lang.String getScopedAsync(AjaxGroup aGroup, AjaxElement aElement, AjaxEvent aEvent)
          This method returns the async for a given event based on scope rules.
static java.lang.String getScopedForm(AjaxGroup aGroup, AjaxElement aElement, AjaxEvent aEvent)
          This method returns the form for a given event based on scope rules.
static java.lang.String getScopedMethod(AjaxGroup aGroup, AjaxElement aElement, AjaxEvent aEvent)
          This method returns the method for a given event based on scope rules.
static java.lang.String getScopedPostProc(AjaxGroup aGroup, AjaxElement aElement, AjaxEvent aEvent)
          This method returns the postPRoc for a given event based on scope rules.
static java.lang.String getScopedPreProc(AjaxGroup aGroup, AjaxElement aElement, AjaxEvent aEvent)
          This method returns the preProc for a given event based on scope rules.
private static java.io.InputStream getStream(java.lang.String inResName)
          This method returns an InputStream on a resource loaded from the classpath, including within a JAR file.
static java.lang.String groupRefFromAjaxRef(java.lang.String ajaxRef)
          This method takes an ajaxRef (which is assumed to be in the correct format) and returns just the group's ajaxRef.
private static java.lang.String stringFromInputStream(java.io.InputStream inIS)
          This method takes as input an InputStream and returns it as a String.
static void updatePageScopeVars(java.lang.String ajaxRef, javax.servlet.jsp.PageContext pageContext, AjaxGroup aGroup, AjaxElement aElement)
          This method updates the two page-scope collections that is built up as event, manual and timer tags are encountered and which store all the ajaxREFs and handlers (request, response oe error) encountered on the JSP.
static boolean validateAjaxRef(java.lang.String ajaxRef)
          This method validates that a string purported to be an ajaxRef is in the form xxxx/yyyy.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static org.apache.commons.logging.Log log
Log instance.

Constructor Detail

AjaxUtils

private AjaxUtils()
This is a utility class, so we want a private noarg constructor so instances cannot be created.

Method Detail

getResource

public static java.lang.String getResource(java.lang.String inResName)
This method returns a String from a resource loaded from the classpath, including within a JAR file.

Parameters:
inResName - The name of the resource to load. This should be a path specifier WITHOUT a leading slash.
Returns:
A String of the request resource, or null if the resource is not found.

getStream

private static java.io.InputStream getStream(java.lang.String inResName)
This method returns an InputStream on a resource loaded from the classpath, including within a JAR file.

Parameters:
inResName - The name of the resource to load. This should be a path specifier WITHOUT a leading slash.
Returns:
An InputStream on the request resource, or null if the resource is not found.

stringFromInputStream

private static java.lang.String stringFromInputStream(java.io.InputStream inIS)
This method takes as input an InputStream and returns it as a String.

Parameters:
inIS - The InputStream to "convert".
Returns:
The InputStream as a String, or null if the InputStream passed in was null.

validateAjaxRef

public static boolean validateAjaxRef(java.lang.String ajaxRef)
This method validates that a string purported to be an ajaxRef is in the form xxxx/yyyy.

Parameters:
ajaxRef - The purported ajaxRef to validate.
Returns:
True if it is in the proper xxxx/yyyy form, false if not.

groupRefFromAjaxRef

public static java.lang.String groupRefFromAjaxRef(java.lang.String ajaxRef)
This method takes an ajaxRef (which is assumed to be in the correct format) and returns just the group's ajaxRef.

Parameters:
ajaxRef - The ajaxRef.
Returns:
The group ajaxRef.

elementRefFromAjaxRef

public static java.lang.String elementRefFromAjaxRef(java.lang.String ajaxRef)
This method takes an ajaxRef (which is assumed to be in the correct format) and returns just the element's ajaxRef.

Parameters:
ajaxRef - The ajaxRef.
Returns:
The element ajaxRef.

updatePageScopeVars

public static void updatePageScopeVars(java.lang.String ajaxRef,
                                       javax.servlet.jsp.PageContext pageContext,
                                       AjaxGroup aGroup,
                                       AjaxElement aElement)
This method updates the two page-scope collections that is built up as event, manual and timer tags are encountered and which store all the ajaxREFs and handlers (request, response oe error) encountered on the JSP.

Parameters:
ajaxRef - The ajaxRef of the tag being handled.
pageContext - The PageContext of the JSP being rendered.
aGroup - The AjaxGroup instance that is the parent of the element referenced by the tag that called this.
aElement - The AjaxElement instance that of the element referenced by the tag that called this.

getScopedForm

public static java.lang.String getScopedForm(AjaxGroup aGroup,
                                             AjaxElement aElement,
                                             AjaxEvent aEvent)
This method returns the form for a given event based on scope rules. This value can be defined on the group, element or event levels, and in that order they override each other. Note that the default values are defined in the AjaxGroup class.

Parameters:
aGroup - The AjaxGroup that is parent to this event.
aElement - The AjaxElement that is parent to this event.
aEvent - The AjaxEvent that is parent to this event.
Returns:
The value for the form attribute.

getScopedMethod

public static java.lang.String getScopedMethod(AjaxGroup aGroup,
                                               AjaxElement aElement,
                                               AjaxEvent aEvent)
This method returns the method for a given event based on scope rules. This value can be defined on the group, element or event levels, and in that order they override each other. Note that the default values are defined in the AjaxGroup class.

Parameters:
aGroup - The AjaxGroup that is parent to this event.
aElement - The AjaxElement that is parent to this event.
aEvent - The AjaxEvent that is parent to this event.
Returns:
The value for the form attribute.

getScopedAsync

public static java.lang.String getScopedAsync(AjaxGroup aGroup,
                                              AjaxElement aElement,
                                              AjaxEvent aEvent)
This method returns the async for a given event based on scope rules. This value can be defined on the group, element or event levels, and in that order they override each other. Note that the default values are defined in the AjaxGroup class.

Parameters:
aGroup - The AjaxGroup that is parent to this event.
aElement - The AjaxElement that is parent to this event.
aEvent - The AjaxEvent that is parent to this event.
Returns:
The value for the form attribute.

getScopedPreProc

public static java.lang.String getScopedPreProc(AjaxGroup aGroup,
                                                AjaxElement aElement,
                                                AjaxEvent aEvent)
This method returns the preProc for a given event based on scope rules. This value can be defined on the group, element or event levels, and in that order they override each other. Note that the default values are defined in the AjaxGroup class.

Parameters:
aGroup - The AjaxGroup that is parent to this event.
aElement - The AjaxElement that is parent to this event.
aEvent - The AjaxEvent that is parent to this event.
Returns:
The value for the form attribute.

getScopedPostProc

public static java.lang.String getScopedPostProc(AjaxGroup aGroup,
                                                 AjaxElement aElement,
                                                 AjaxEvent aEvent)
This method returns the postPRoc for a given event based on scope rules. This value can be defined on the group, element or event levels, and in that order they override each other. Note that the default values are defined in the AjaxGroup class.

Parameters:
aGroup - The AjaxGroup that is parent to this event.
aElement - The AjaxElement that is parent to this event.
aEvent - The AjaxEvent that is parent to this event.
Returns:
The value for the form attribute.


Copyright © 2005 Frank W. Zammetti