Can't use the callback option of AJAX.AutoComplete, because there is no way to
produce a quoteless value in a JSONObject
------------------------------------------------------------------------------------------------------------------------
Key: TAPESTRY-2298
URL: https://issues.apache.org/jira/browse/TAPESTRY-2298
Project: Tapestry
Issue Type: Bug
Components: Core Components
Affects Versions: 5.0.12
Environment: osx 10.5, java 1.5
Reporter: Julian Wood
If you extend Autocomplete, and override the configure method like so:
protected void configure(JSONObject config)
{
config.put("callback", "myMethod");
}
and in my javascript I have:
function myMethod(element, entry) {
console.info(element);
console.info(entry);
return entry;
}
This doesn't work because myMethod is quoted in javascript, and needs to be
unquoted:
new AJAX.AutoComplete('provinceState', 'provinceState:menu',
'/webapp/signup.provincestate:autocomplete',
{"indicator":"provinceState:loader","callback":"myMethod","paramName":"t:input"});
should be
new AJAX.AutoComplete('provinceState', 'provinceState:menu',
'/webapp/signup.provincestate:autocomplete',
{"indicator":"provinceState:loader","callback":myMethod,"paramName":"t:input"});
Note the absence of quotes around myMethod.
So it seems I should be able to put an object into the config which returns an
unquoted string:
protected void configure(JSONObject config)
{
config.put("callback", new JSONString() {
public String toJSONString() {
return "myMethod";
}
});
}
However, this errors because the allowed types for the JSONObject.put method
seem restricted to these:
private static final Class[] ALLOWED = new Class[] { String.class,
Boolean.class, Number.class, JSONObject.class, JSONArray.class, Null.class };
This, despite the fact that the method JSONObject.valueToString(Object value)
looks for an object of type JSONString.
I can't extend JSONObject with my own toJSONString() impl, because JSONObject
is final.
All that is needed is JSONString.class in ALLOWED.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]