net.sf.tacos.ajax
Class AjaxUtils

java.lang.Object
  extended by net.sf.tacos.ajax.AjaxUtils

public class AjaxUtils
extends Object

Utility class for ajax operation

Author:
Felix Sun

Constructor Summary
AjaxUtils()
           
 
Method Summary
static String createOnclickHandler(AjaxInvocation invocation, boolean globalScope)
          Creates the onclick handler, to be used in links having ajax functionality.
static String getLinkArguments(AjaxInvocation invocation, boolean globalScope)
          Generates a js structure, optionally making it globally safe to use.
static String getLinkString(AjaxInvocation invocation, boolean globalScope)
          Generates a javascript function call, optionally making it globally safe to use.
static boolean isAjaxCycle(org.apache.tapestry.IRequestCycle cycle)
          Returns true if the request is Ajax.
static boolean isAjaxRequest(AjaxDirectService service)
          Indicate whether the current request is an ajax request.
static void linkFieldObservers(org.apache.tapestry.IRequestCycle cycle, org.apache.tapestry.services.ExpressionEvaluator eval, AjaxWebRequest ajaxr, org.apache.tapestry.IComponent comp, org.apache.tapestry.PageRenderSupport prs, String eventListener)
          Connects a given IFormComponent to a client-side javascript event that will cause whatever action has been specified on the field via a DeferredScriptProducer component.
static void linkFieldObservers(org.apache.tapestry.IRequestCycle cycle, org.apache.tapestry.services.ExpressionEvaluator eval, AjaxWebRequest ajaxr, org.apache.tapestry.IComponent comp, String uniqueId, org.apache.tapestry.PageRenderSupport prs, String eventListener)
          Connects a given IFormComponent to a client-side javascript event that will cause whatever action has been specified on the field via a DeferredScriptProducer component.
static void putAjaxParameter(AjaxInvocation ajaxInvocation, Map parameters, org.apache.tapestry.IRequestCycle cycle)
          Put standard ajax parameters to an Map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AjaxUtils

public AjaxUtils()
Method Detail

isAjaxRequest

public static final boolean isAjaxRequest(AjaxDirectService service)
Indicate whether the current request is an ajax request.

Parameters:
service -
Returns:
ajax request or not.

isAjaxCycle

public static boolean isAjaxCycle(org.apache.tapestry.IRequestCycle cycle)
Returns true if the request is Ajax.

Parameters:
cycle - The Tapestry request cycle.
Returns:
True if the request is Ajax.

putAjaxParameter

public static void putAjaxParameter(AjaxInvocation ajaxInvocation,
                                    Map parameters,
                                    org.apache.tapestry.IRequestCycle cycle)
Put standard ajax parameters to an Map.

Parameters:
ajaxInvocation -
parameters -
cycle -

linkFieldObservers

public static void linkFieldObservers(org.apache.tapestry.IRequestCycle cycle,
                                      org.apache.tapestry.services.ExpressionEvaluator eval,
                                      AjaxWebRequest ajaxr,
                                      org.apache.tapestry.IComponent comp,
                                      org.apache.tapestry.PageRenderSupport prs,
                                      String eventListener)
Connects a given IFormComponent to a client-side javascript event that will cause whatever action has been specified on the field via a DeferredScriptProducer component.

Incoming string should look like "onchange=components.observer1,onblur=components.observer2"

Parameters:
cycle - the current request
eval - OGNL expression parser
ajaxr - the ajax request
comp - component being referenced
prs - the script contribution engine
eventListener - command string

linkFieldObservers

public static void linkFieldObservers(org.apache.tapestry.IRequestCycle cycle,
                                      org.apache.tapestry.services.ExpressionEvaluator eval,
                                      AjaxWebRequest ajaxr,
                                      org.apache.tapestry.IComponent comp,
                                      String uniqueId,
                                      org.apache.tapestry.PageRenderSupport prs,
                                      String eventListener)
Connects a given IFormComponent to a client-side javascript event that will cause whatever action has been specified on the field via a DeferredScriptProducer component.

Incoming string should look like "onchange=components.observer1,onblur=components.observer2".

Parameters:
cycle - the current request
eval - OGNL expression parser
ajaxr - the ajax request
comp - component being referenced
uniqueId - overriden unique id
prs - the script contribution engine
eventListener - command string

getLinkArguments

public static String getLinkArguments(AjaxInvocation invocation,
                                      boolean globalScope)
Generates a js structure, optionally making it globally safe to use.

Parameters:
invocation -
globalScope - Should be true if the returned structure is to be used in other components (or for anything not directly related to the given AjaxInvocation).
Returns:

getLinkString

public static String getLinkString(AjaxInvocation invocation,
                                   boolean globalScope)
Generates a javascript function call, optionally making it globally safe to use. When the returned script is executed, it initiates and completely handles an ajax-request (and its results).

Parameters:
globalScope - Should be true if the returned javascript is to be used in other components (or for anything not related to the creation of this link's markup).
Returns:

createOnclickHandler

public static String createOnclickHandler(AjaxInvocation invocation,
                                          boolean globalScope)
Creates the onclick handler, to be used in links having ajax functionality.

Parameters:
invocation -
Returns: