Details
-
Improvement
-
Status: Closed
-
Major
-
Resolution: Fixed
-
5.2
-
None
Description
I quite often needed to initialise an XHR request-response from javascript. I think it would be a very useful feature for tapestry to expose to it's users.
The ideal solution would
1. not require a zone for wiring (see #TAP5-1404)
2. encode context parameters as per server side
EG
I ended up writing a function to facilitate this. It handles:
1. the zone wiring
2. context parameters (unfortunately does not properly conform to encoding rules as per server side generated params)
3. query strings (sometimes useful)
4. url based session ids (for when cookies are disabled)
note that the url is usually generated at the server side via ComponentResources.createEventLink.
function multiZoneUpdate(url, params, zoneId)
{
// wire up zone, use dummy if none supplied
if (typeof(zoneId) == "undefined")
zoneId = "dummyZone";
var zoneObject = Tapestry.findZoneManagerForZone(zoneId);
if (!zoneObject)
throw "unknown zone: " + zoneId;
// context params must be an array
if (!(params instanceof Array))
params = [params];
// include query string if supplied
var qs = "";
var qsInd = url.indexOf("?");
if (qsInd != -1)
// include jsessionid if exists
var jsId = "";
var jsInd = url.indexOf(";");
if (jsInd != -1)
// build url
if (params != null)
for (var p = 0; p < params.length; p++)
url += "/" + params[p];
// request
zoneObject.updateFromURL(url + jsId + qs);
}
Attachments
Issue Links
- relates to
-
TAP5-2021 create compatible client side method of encoding context parameters
- Closed