[ https://issues.apache.org/jira/browse/TAP5-1405?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13720185#comment-13720185 ]
Paul Stanton commented on TAP5-1405: ------------------------------------ does it handle encoding context parameters? > XHR requests should be easily callable from javascript and not rely on a zone > ----------------------------------------------------------------------------- > > Key: TAP5-1405 > URL: https://issues.apache.org/jira/browse/TAP5-1405 > Project: Tapestry 5 > Issue Type: Improvement > Components: tapestry-core > Affects Versions: 5.2 > Reporter: Paul Stanton > Assignee: Howard M. Lewis Ship > Fix For: 5.4 > > > 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) > { > qs = url.substring(qsInd); > url = url.substring(0, qsInd); > } > // include jsessionid if exists > var jsId = ""; > var jsInd = url.indexOf(";"); > if (jsInd != -1) > { > jsId = url.substring(jsInd); > url = url.substring(0, jsInd); > } > // build url > if (params != null) > for (var p = 0; p < params.length; p++) > url += "/" + params[p]; > // request > zoneObject.updateFromURL(url + jsId + qs); > } -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira