tapestry

Provides the core functionality for the Tapestry javascript package libraries.

Most of the functions in here are related to initiating and parsing IO requests.

Summary
tapestryProvides the core functionality for the Tapestry javascript package libraries.
Properties
versionThe current client side library version, usually matching the current java library version.
requestEncodingDefines the encoding that will be used in all Tapestry initiated XHR requests to encode URL or form data.
Functions
bindCore XHR bind function for tapestry internals.
errorGlobal error handling function for dojo.io.bind requests.
loadGlobal load handling function for dojo.io.bind requests.
loadJson
loadContentUsed by tapestry.load when handling xml responses to iterate over the tapestry specific xml response and appropriately load all content types / perform animations / execute scripts in the proper order / etc..
loadScriptContentManages loading javascript content for a specific incoming xml element.
loadScriptFromUrlTakes a url string and loads the javascript it points to as a normal document head script include section.
presentExceptionWhen remote exceptions are caught on the server special xml blocks are returned to the client when the requests are initiated via async IO.
cleanConnectUtility used to disconnect a previously connected event/function.
isServingRequestsUtility used to find out if there are any ajax requests in progress.
tapestry.htmlProvides functionality related to parsing and rendering dom nodes.
Functions
getContentAsStringTakes a dom node and returns its contents rendered in a string.
getElementAsStringTakes a dom node and returns itself and its contents rendered in a string.
tapestry. eventUtility functions that handle converting javascript event objects into a name/value pair format that can be sent to the remote server.
Functions
buildEventPropertiesTakes an incoming browser generated event (like key/mouse events) and creates a js object holding the basic values of the event in order for it to be submitted to the server.
buildTargetPropertiesGeneric function to build a properties object populated with relevent target data.
buildNodePropertiesBuilds needed target node properties, like the node’s id.

Properties

version

The current client side library version, usually matching the current java library version.  (ie 4.1, etc..)

requestEncoding

Defines the encoding that will be used in all Tapestry initiated XHR requests to encode URL or form data.  Gets set by AjaxShellDelegate class on server on most requests by default.

Functions

bind

bind:function(url,
content,
json)

Core XHR bind function for tapestry internals.  The error/load functions defined in this package are used to handle load/error of dojo.io.bind.

Parameters

urlThe url to bind the request to.
contentA properties map of optional extra content to send.
jsonBoolean, optional parameter specifying whether or not to create a json request.  If not specified the default is to use XHR.

error

error:function(type,
exception,
http,
kwArgs)

Global error handling function for dojo.io.bind requests.  This function is mapped as the “error:functionName” part of a request in the dojo.io.bind arguments in tapestry.bind calls.

See Also

tapestry.bind, tapestry.load

load

load:function(type,
data,
http,
kwArgs)

Global load handling function for dojo.io.bind requests.  This isn’t typically called directly by anything, but passed in as the “load” argument to dojo.io.bind when making IO requests as the function that will handle the return response.

Parameters

typeType of request.
dataThe data returned, depending on the request type might be an xml document / plaintext / json / etc.
httpThe http object used in request, like XmlHttpRequest.
kwArgsThe original set of arguments passed into dojo.io.bind({arg:val,arg1:val2}).

loadJson

loadJson:function(type,
data,
http,
kwArgs)
Executed by default during JSON requestsdefault implementation does nothing but decrement the <tapestry.requestsInFlight> global variable.

Parameters

typeType of request.
dataThe data returned, depending on the request type might be an xml document / plaintext / json / etc.
httpThe http object used in request, like XmlHttpRequest.
kwArgsThe original set of arguments passed into dojo.io.bind({arg:val,arg1:val2}).

loadContent

loadContent:function(id,
node,
element)

Used by tapestry.load when handling xml responses to iterate over the tapestry specific xml response and appropriately load all content types / perform animations / execute scripts in the proper order / etc..

Parameters

idThe element id that this content should be applied to in the existing document.
nodeThe node that this new content will be applied to.
elementThe incoming xml node containing rules/content to apply to this node.

loadScriptContent

loadScriptContent:function(element,
async)

Manages loading javascript content for a specific incoming xml element.

Parameters

elementThe element to parse javascript statements from and execute.
asyncWhether or not to process the script content asynchronously, meaning whether or not to execute the script in a block done in a setTimeout call so as to avoid IE specific issues.

loadScriptFromUrl

loadScriptFromUrl:function(url)

Takes a url string and loads the javascript it points to as a normal document head script include section. ie:

<script type="text/javascript" src="http://localhost/js/foo.js"></script>

Parameters

urlThe url to the script to load into this documents head.

presentException

presentException:function(node,
kwArgs)

When remote exceptions are caught on the server special xml blocks are returned to the client when the requests are initiated via async IO.  This function takes the incoming Tapestry exception page content and dumps it into a modal dialog that is presented to the user.

Parameters

nodeThe incoming xml exception node.
kwArgsThe kwArgs used to initiate the original IO request.

cleanConnect

cleanConnect:function(target,
event,
funcName)

Utility used to disconnect a previously connected event/function.

This assumes that the incoming function name is being attached to the global namespace “tapestry”.

isServingRequests

isServingRequests:function()

Utility used to find out if there are any ajax requests in progress.

tapestry.html

Provides functionality related to parsing and rendering dom nodes.

Summary
Functions
getContentAsStringTakes a dom node and returns its contents rendered in a string.
getElementAsStringTakes a dom node and returns itself and its contents rendered in a string.

Functions

getContentAsString

getContentAsString:function(node)

Takes a dom node and returns its contents rendered in a string.

The resulting string does NOT contain any markup (or attributes) of the given node - only child nodes are rendered and returned.Content

Implementation Note: This function tries to make use of browser specific features (the xml attribute of nodes in IE and the XMLSerializer object in Mozilla derivatives) - if those fails, a generic implementation is used that is guaranteed to work in all platforms.

Parameters

nodeThe dom node.  Returns:

The string representation of the given node’s contents.

getElementAsString

getElementAsString:function(node)

Takes a dom node and returns itself and its contents rendered in a string.

Implementation Note: This function uses a generic implementation in order to generate the returned string.

Parameters

nodeThe dom node.  Returns:

The string representation of the given node.

tapestry. event

Utility functions that handle converting javascript event objects into a name/value pair format that can be sent to the remote server.

Summary
Functions
buildEventPropertiesTakes an incoming browser generated event (like key/mouse events) and creates a js object holding the basic values of the event in order for it to be submitted to the server.
buildTargetPropertiesGeneric function to build a properties object populated with relevent target data.
buildNodePropertiesBuilds needed target node properties, like the node’s id.

Functions

buildEventProperties

buildEventProperties:function(event,
props)

Takes an incoming browser generated event (like key/mouse events) and creates a js object holding the basic values of the event in order for it to be submitted to the server.

Parameters

eventThe javascript event method is based on, if it isn’t a valid browser event it will be ignored.
propsThe existing property object to set the values on, if it doesn’t exist one will be created.  Returns:

The desired event properties bound to an object.  Ie obj.target,obj.charCode, etc..

buildTargetProperties

buildTargetProperties:function(props,
target)

Generic function to build a properties object populated with relevent target data.

Parameters

propsThe object that event properties are being set on to return to the server.
targetThe javscript Event.target object that the original event was targeted for.

Returns

The original props object passed in, populated with any data found.

buildNodeProperties

buildNodeProperties:function(props,
node)

Builds needed target node properties, like the node’s id.

Parameters

propsThe object that event properties are being set on to return to the server.
nodeThe dom node specified as the Event.target in a javascript event.
bind:function(url,
content,
json)
Core XHR bind function for tapestry internals.
error:function(type,
exception,
http,
kwArgs)
Global error handling function for dojo.io.bind requests.
load:function(type,
data,
http,
kwArgs)
Global load handling function for dojo.io.bind requests.
loadJson:function(type,
data,
http,
kwArgs)
loadContent:function(id,
node,
element)
Used by tapestry.load when handling xml responses to iterate over the tapestry specific xml response and appropriately load all content types / perform animations / execute scripts in the proper order / etc..
loadScriptContent:function(element,
async)
Manages loading javascript content for a specific incoming xml element.
loadScriptFromUrl:function(url)
Takes a url string and loads the javascript it points to as a normal document head script include section.
presentException:function(node,
kwArgs)
When remote exceptions are caught on the server special xml blocks are returned to the client when the requests are initiated via async IO.
cleanConnect:function(target,
event,
funcName)
Utility used to disconnect a previously connected event/function.
isServingRequests:function()
Utility used to find out if there are any ajax requests in progress.
getContentAsString:function(node)
Takes a dom node and returns its contents rendered in a string.
getElementAsString:function(node)
Takes a dom node and returns itself and its contents rendered in a string.
buildEventProperties:function(event,
props)
Takes an incoming browser generated event (like key/mouse events) and creates a js object holding the basic values of the event in order for it to be submitted to the server.
buildTargetProperties:function(props,
target)
Generic function to build a properties object populated with relevent target data.
buildNodeProperties:function(props,
node)
Builds needed target node properties, like the node’s id.