[ https://issues.apache.org/jira/browse/TAP5-2021?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13485285#comment-13485285 ]
Paul Stanton edited comment on TAP5-2021 at 10/30/12 4:04 AM: -------------------------------------------------------------- here is a javascript version of URLEncoderImpl.encode /** * see org.apache.tapestry5.internal.services.URLEncoderImpl.encode(String) * correct as at tapestry 5.3.5 */ function tapestryUrlEncodeParameter(input) { var safe = "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "01234567890-_.:"; if (input === null) return "$N"; if (input === "") return "$B"; var length = input.length; var output = ""; for (var i = 0; i < length; i++) { var ch = input.charAt(i); if (ch == '$') { output.append("$$"); continue; } if (safe.indexOf(ch) != -1) { output += ch; continue; } var chHex = ch.charCodeAt(0).toString(16); while (chHex.length < 4) chHex = "0" + chHex; output += "$" + chHex; } return output; } was (Author: paul.stanton): here is a javascript version of URLEncoderImpl.encode /** * see org.apache.tapestry5.internal.services.URLEncoderImpl.encode(String) * correct as at tapestry 5.3.5 */ function tapestryUrlEncodeParameter(input) { var safe = "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "01234567890-_.:"; if (input === null) return "$N"; if (input === "") return "$B"; var length = input.length; var output = ""; for (var i = 0; i < length; i++) { var ch = input.charAt(i); if (ch == '$') { output.append("$$"); continue; } if (safe.indexOf(ch) != -1) { output += ch; continue; } var chAsInt = ch.charCodeAt(0); var chAsHexInt = parseInt(chAsInt.toString(16)); output += "$" + chAsHexInt.toPaddedString(4); } return output; } > create compatible client side method of encoding context parameters > ------------------------------------------------------------------- > > Key: TAP5-2021 > URL: https://issues.apache.org/jira/browse/TAP5-2021 > Project: Tapestry 5 > Issue Type: Improvement > Components: tapestry-core > Affects Versions: 5.3 > Reporter: Paul Stanton > Labels: urlencoder > > Currently there is no (provided) way to replicate the tapestry propriety URL > encoding. > See org.apache.tapestry5.internal.services.URLEncoderImpl.encode(String) > This can be limiting for advanced users wiring up custom components which may > create requests via javascript. > I personally have come up against this a number of times. > I propose that tapestry.js include a function which does the equivalent of > URLEncoder.encode, or even better, ComponentResources.createEventLink etc. -- 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