You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by "Julian Wood (JIRA)" <de...@tapestry.apache.org> on 2008/03/26 18:41:25 UTC
[jira] Created: (TAPESTRY-2298) Can't use the callback option of
AJAX.AutoComplete, because there is no way to produce a quoteless value in
a JSONObject
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: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org
[jira] Resolved: (TAPESTRY-2298) Can't use the callback option of
AJAX.AutoComplete, because there is no way to produce a quoteless value in
a JSONObject
Posted by "Julian Wood (JIRA)" <de...@tapestry.apache.org>.
[ https://issues.apache.org/jira/browse/TAPESTRY-2298?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Julian Wood resolved TAPESTRY-2298.
-----------------------------------
Resolution: Duplicate
This is the same as TAPESTRY-2234
> 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: tapestry-core
> 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: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org
[jira] Updated: (TAPESTRY-2298) Can't use the callback option of
AJAX.AutoComplete, because there is no way to produce a quoteless value in
a JSONObject
Posted by "Julian Wood (JIRA)" <de...@tapestry.apache.org>.
[ https://issues.apache.org/jira/browse/TAPESTRY-2298?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Julian Wood updated TAPESTRY-2298:
----------------------------------
Component/s: (was: Core Components)
tapestry-core
> 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: tapestry-core
> 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: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org