You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by JWiegman <Jo...@dswinc.com> on 2008/04/11 19:17:19 UTC
Re: JSONObject problem and Autocomplete
Julian,
Did you ever find a fix for this? I'm running into the same issue...
Thanks,
Joel
Julian Wood wrote:
>
> I was just extending Autocomplete, and I wanted to add a callback to
> the config, so I override the config:
>
> 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.
>
> Bug? All that is needed is JSONString.class in ALLOWED.
>
> Thanks,
>
> J
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/JSONObject-problem-and-Autocomplete-tp16171055p16628158.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
RE: JSONObject problem and Autocomplete
Posted by Joel Wiegman <Jo...@dswinc.com>.
Just to close the thread, I see that there's an existing bug for this
problem:
https://issues.apache.org/jira/browse/TAPESTRY-2234
-----Original Message-----
From: JWiegman [mailto:JoelWiegman@dswinc.com]
Sent: Friday, April 11, 2008 1:17 PM
To: users@tapestry.apache.org
Subject: Re: JSONObject problem and Autocomplete
Julian,
Did you ever find a fix for this? I'm running into the same issue...
Thanks,
Joel
Julian Wood wrote:
>
> I was just extending Autocomplete, and I wanted to add a callback to
> the config, so I override the config:
>
> 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.
>
> Bug? All that is needed is JSONString.class in ALLOWED.
>
> Thanks,
>
> J
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
>
--
View this message in context:
http://www.nabble.com/JSONObject-problem-and-Autocomplete-tp16171055p166
28158.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org