You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by "Paul Stanton (JIRA)" <ji...@apache.org> on 2012/10/27 01:39:12 UTC
[jira] [Updated] (TAP5-2021) create compatible client side method
of encoding context parameters
[ https://issues.apache.org/jira/browse/TAP5-2021?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul Stanton updated TAP5-2021:
-------------------------------
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