net.sf.tacos.ajax.impl
Class AjaxWebRequestImpl

java.lang.Object
  extended by net.sf.tacos.ajax.impl.AjaxWebRequestImpl
All Implemented Interfaces:
AjaxWebRequest

public class AjaxWebRequestImpl
extends Object
implements AjaxWebRequest

Implementation of AjaxWebRequest.

Author:
jkuhnert

Field Summary
protected  Map deferredScripts
          Deferred scripts
protected  boolean directUpdate
          Whether or not is directly updating components
protected  String focusElement
          Element to focus after the request.
protected  boolean processScripts
          Whether or not we're processing scripts
protected  ResponseBuilder responseBuilder
          Component update invoker
protected  String type
          Type of request
protected  SortedSet updateComponents
          Update components
protected  String version
          Version of client library request
protected  List visibleWidgets
          Visible widgets
 
Fields inherited from interface net.sf.tacos.ajax.AjaxWebRequest
AJAX_REQUEST, AJAX_REQUEST_TYPE, PROTOTYPE_VERSION_HEADER, REQUEST_TYPE_HEADER
 
Constructor Summary
AjaxWebRequestImpl()
          Default constructor
 
Method Summary
 void addDeferredScript(String id, org.apache.tapestry.IScript script, Map parms)
          Adds a script to be executed when the component specified by the IFormComponent with a component id matching id.
 void addPostProcessScript(String script)
          In whatever form the ResponseBuilder associated with this request supports it, the script specified will be executed just after the content replacement on the client, before normal javascript is executed.
 void addPreProcessScript(String script)
          In whatever form the ResponseBuilder associated with this request supports it, the script specified will be executed first on the client before anything else.
 void addStatusResponse(String status)
          Sets the returned response status text, if configured in the AjaxDirectLink or AjaxForm components.
 void addUpdateComponent(String id)
          Adds a component to be refreshed on this request.
 void clearDeferredScripts(String id)
          Clears all previously stored deferred scripts for the specified component id.
 boolean containsComponentId(String id)
          Checks if this request contains the specified component id.
 List getDeferredScripts(String id)
          Gets a List of scripts to be executed by the specified component when rendering, the List returned, if not null, will contain a list of Map objects with the IScript and Map parameters for the script.
 String getFocusElement()
          Gets an element to focus after rendering the ajax response.
 ResponseBuilder getResponseBuilder()
          The class responsible for invoking and rendering the responses received from components.
 String getType()
          The type of ajax request made, which should be AjaxWebRequest.AJAX_REQUEST_TYPE in all cases for now.
 SortedSet getUpdateComponents()
          List of unique component id's that will have their contents refreshed on this request.
 String getVersion()
          The version of the ajax client library that was used to invoke the ajax cycle.
 boolean isDirectUpdate()
          Whether or not this request expects components to be updated directly, without requiring that the entire page be rendered.
 boolean isProcessScripts()
          Whether or not the client call has requested that the server process scripts.
 boolean isValidRequest()
          For instances where an ajax request link was setup, but the client invocation of that link could not create a valid ajax request for one reason or another.
 boolean isWidgetVisible(String id)
          Checks if the client-side widget with a unique id matching the specified string is visible already.
 void removeUpdateComponent(String id)
          Removes the specifiec component from this partial render.
 void setDirectUpdate(boolean directUpdate)
          Sets whether or not this request should directly update components.
 void setFocusElement(String id)
          Sets an element id to focus after rendering the ajax response.
 void setProcessScripts(boolean value)
          Sets whether or not should process javascript.
 void setResponseBuilder(ResponseBuilder responseBuilder)
          Sets the response builder.
 void setType(String type)
          Sets the type of ajax request.
 void setVersion(String version)
          Sets the request version.
 void setVisibleWidgets(List ids)
          Sets the list of currently visible dojo widgets.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

type

protected String type
Type of request


version

protected String version
Version of client library request


updateComponents

protected SortedSet updateComponents
Update components


processScripts

protected boolean processScripts
Whether or not we're processing scripts


directUpdate

protected boolean directUpdate
Whether or not is directly updating components


responseBuilder

protected ResponseBuilder responseBuilder
Component update invoker


visibleWidgets

protected List visibleWidgets
Visible widgets


deferredScripts

protected Map deferredScripts
Deferred scripts


focusElement

protected String focusElement
Element to focus after the request.

Constructor Detail

AjaxWebRequestImpl

public AjaxWebRequestImpl()
Default constructor

Method Detail

getType

public String getType()
The type of ajax request made, which should be AjaxWebRequest.AJAX_REQUEST_TYPE in all cases for now.

Specified by:
getType in interface AjaxWebRequest
Returns:
The string found in header for AjaxWebRequest.REQUEST_TYPE_HEADER.

setType

public void setType(String type)
Sets the type of ajax request.

Specified by:
setType in interface AjaxWebRequest

getVersion

public String getVersion()
The version of the ajax client library that was used to invoke the ajax cycle.

Specified by:
getVersion in interface AjaxWebRequest
Returns:
Currently the value of AjaxWebRequest.PROTOTYPE_VERSION_HEADER header.

setVersion

public void setVersion(String version)
Sets the request version.

Specified by:
setVersion in interface AjaxWebRequest

addUpdateComponent

public void addUpdateComponent(String id)
Adds a component to be refreshed on this request.

Specified by:
addUpdateComponent in interface AjaxWebRequest

getUpdateComponents

public SortedSet getUpdateComponents()
List of unique component id's that will have their contents refreshed on this request.

Specified by:
getUpdateComponents in interface AjaxWebRequest
Returns:

removeUpdateComponent

public void removeUpdateComponent(String id)
Removes the specifiec component from this partial render.

Specified by:
removeUpdateComponent in interface AjaxWebRequest

isValidRequest

public boolean isValidRequest()
For instances where an ajax request link was setup, but the client invocation of that link could not create a valid ajax request for one reason or another. If this is true the response will be rendered back to the client in text/html mode as a normal request.

Specified by:
isValidRequest in interface AjaxWebRequest
Returns:

isDirectUpdate

public boolean isDirectUpdate()
Whether or not this request expects components to be updated directly, without requiring that the entire page be rendered.

Specified by:
isDirectUpdate in interface AjaxWebRequest
Returns:
True if components are updated directly, false otherwise.

setDirectUpdate

public void setDirectUpdate(boolean directUpdate)
Sets whether or not this request should directly update components.

Specified by:
setDirectUpdate in interface AjaxWebRequest

isProcessScripts

public boolean isProcessScripts()
Whether or not the client call has requested that the server process scripts. ResponseContributors can use this knowledge in their response.

By default this value is always true, unless the client call has set it explicitly.

Specified by:
isProcessScripts in interface AjaxWebRequest
Returns:

setProcessScripts

public void setProcessScripts(boolean value)
Sets whether or not should process javascript.

Specified by:
setProcessScripts in interface AjaxWebRequest

getResponseBuilder

public ResponseBuilder getResponseBuilder()
The class responsible for invoking and rendering the responses received from components.

Specified by:
getResponseBuilder in interface AjaxWebRequest
Returns:

setResponseBuilder

public void setResponseBuilder(ResponseBuilder responseBuilder)
Sets the response builder.

Specified by:
setResponseBuilder in interface AjaxWebRequest

containsComponentId

public boolean containsComponentId(String id)
Checks if this request contains the specified component id.

Specified by:
containsComponentId in interface AjaxWebRequest
Parameters:
id - Id returned by invoking IComponent.getId().
Returns:
True if request contains update request for specified component.

addStatusResponse

public void addStatusResponse(String status)
Sets the returned response status text, if configured in the AjaxDirectLink or AjaxForm components.

Specified by:
addStatusResponse in interface AjaxWebRequest

addPreProcessScript

public void addPreProcessScript(String script)
In whatever form the ResponseBuilder associated with this request supports it, the script specified will be executed first on the client before anything else.

Specified by:
addPreProcessScript in interface AjaxWebRequest

addPostProcessScript

public void addPostProcessScript(String script)
In whatever form the ResponseBuilder associated with this request supports it, the script specified will be executed just after the content replacement on the client, before normal javascript is executed.

Specified by:
addPostProcessScript in interface AjaxWebRequest

isWidgetVisible

public boolean isWidgetVisible(String id)
Checks if the client-side widget with a unique id matching the specified string is visible already.

Specified by:
isWidgetVisible in interface AjaxWebRequest
Parameters:
id - The unqiue widget id to check visibility of
Returns:
True if the widget should already be visible

setVisibleWidgets

public void setVisibleWidgets(List ids)
Sets the list of currently visible dojo widgets.

Specified by:
setVisibleWidgets in interface AjaxWebRequest
Parameters:
ids - The list of ids generated from client side call to dojo.widget.manager.widgetids

addDeferredScript

public void addDeferredScript(String id,
                              org.apache.tapestry.IScript script,
                              Map parms)
Adds a script to be executed when the component specified by the IFormComponent with a component id matching id.

Specified by:
addDeferredScript in interface AjaxWebRequest
Parameters:
id - The component id of a valid IFormComponent
script - The javascript template to be executed
parms - Optional paramters to invoke script with

getDeferredScripts

public List getDeferredScripts(String id)
Gets a List of scripts to be executed by the specified component when rendering, the List returned, if not null, will contain a list of Map objects with the IScript and Map parameters for the script.

Specified by:
getDeferredScripts in interface AjaxWebRequest
Parameters:
id - The component id to get scripts for.
Returns:
A List of scripts, or null if none were found.

clearDeferredScripts

public void clearDeferredScripts(String id)
Clears all previously stored deferred scripts for the specified component id.

Specified by:
clearDeferredScripts in interface AjaxWebRequest

getFocusElement

public String getFocusElement()
Gets an element to focus after rendering the ajax response.

Specified by:
getFocusElement in interface AjaxWebRequest
Returns:
The element id to focus.

setFocusElement

public void setFocusElement(String id)
Sets an element id to focus after rendering the ajax response.

Specified by:
setFocusElement in interface AjaxWebRequest
Parameters:
id - the element id to focus.