Re: Tapestry JSONObject : no 'function' type, any workaround ?
Use JSONLiteral. -- View this message in context: http://www.nabble.com/Tapestry-JSONObject-%3A-no-%27function%27-type%2C-any-workaround---tp22369939p23021496.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Tapestry JSONObject : no 'function' type, any workaround ?
Francois Armand wrote: Rico Landefeld wrote: Hello, I had the same annoying problem, but the patch works for me. But my question is: when will be a tapestry maintenance release which contains already this patch? btw, the same problem was solved in tapestry 4.1 long ago. I would like - much prefer in fact - a workaround that does not imply to have my own version of T5... Already does that some times ago for an UTF-8 problem in URLs, and it's a mess to maintain (pom with non standard T5 repos, etc.). So, if someone has a less disruptive workaround, I will be glad to hear it :) (nonetheless, I keep in mind this solution...) Nobody has a real solution ? (real being not patching the framework and maintaining by myself) What I need to do is to create a Window from the Window Prototype. And I'd like to choose the parameters for this object. The js Window object argument is a Javascript Array, with parameters : parameter : value. However some value are Javascript object, for instance showEffect : Element.show What Tapestry write when outputing the JSONObject is showEffect : Element.show. And Element.show is definitively not a JS object. So it fails. Any idea ? Regards, Nicolas - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Tapestry JSONObject : no 'function' type, any workaround ?
toString method of JsonObject would double quote our value. One way is to create some data type extends jsonobject to encapsule your data and override the toString method. I haven't tried it yet. public String toString() { return Element.show; } Thanks, DH - Original Message - From: Nicolas Charles nchar...@linagora.com To: Tapestry users users@tapestry.apache.org Sent: Monday, March 09, 2009 7:35 PM Subject: Re: Tapestry JSONObject : no 'function' type, any workaround ? Francois Armand wrote: Rico Landefeld wrote: Hello, I had the same annoying problem, but the patch works for me. But my question is: when will be a tapestry maintenance release which contains already this patch? btw, the same problem was solved in tapestry 4.1 long ago. I would like - much prefer in fact - a workaround that does not imply to have my own version of T5... Already does that some times ago for an UTF-8 problem in URLs, and it's a mess to maintain (pom with non standard T5 repos, etc.). So, if someone has a less disruptive workaround, I will be glad to hear it :) (nonetheless, I keep in mind this solution...) Nobody has a real solution ? (real being not patching the framework and maintaining by myself) What I need to do is to create a Window from the Window Prototype. And I'd like to choose the parameters for this object. The js Window object argument is a Javascript Array, with parameters : parameter : value. However some value are Javascript object, for instance showEffect : Element.show What Tapestry write when outputing the JSONObject is showEffect : Element.show. And Element.show is definitively not a JS object. So it fails. Any idea ? Regards, Nicolas - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Tapestry JSONObject : no 'function' type, any workaround ?
ningdh wrote: toString method of JsonObject would double quote our value. One way is to create some data type extends jsonobject to encapsule your data and override the toString method. I haven't tried it yet. But JSONObject and JSONArray are final, that's not possible - it was my first plan. How can I workaround that ? -- Francois Armand Etudes Développements J2EE Groupe Linagora - http://www.linagora.com Tél.: +33 (0)1 58 18 68 28 --- http://fanf42.blogspot.com InterLDAP - http://interldap.org FederID - http://www.federid.org/ Open Source identities management and federation - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Tapestry JSONObject : no 'function' type, any workaround ?
Not aware of that, sorry. In my window component, I hack to replace double quote of all function to empty. JSONObject options= new JSONObject(); options.put(showEffect, TO_BE_REPLACE + this.showEffect+TO_BE_REPLACE); getPageRenderSupport().addScript(%s = new Window(%s);, getUniqueId(), filterJsFunction(options.toString())); private String filterJsFunction(String jsonString) { // function begin jsonString = jsonString.replaceAll(\TO_BE_REPLACE, ); // function end jsonString = jsonString.replaceAll(TO_BE_REPLACE\, ); return jsonString; } Well, a bit stupid, but works. DH - Original Message - From: Francois Armand farm...@linagora.com To: Tapestry users users@tapestry.apache.org Sent: Monday, March 09, 2009 9:51 PM Subject: Re: Tapestry JSONObject : no 'function' type, any workaround ? ningdh wrote: toString method of JsonObject would double quote our value. One way is to create some data type extends jsonobject to encapsule your data and override the toString method. I haven't tried it yet. But JSONObject and JSONArray are final, that's not possible - it was my first plan. How can I workaround that ? -- Francois Armand Etudes Développements J2EE Groupe Linagora - http://www.linagora.com Tél.: +33 (0)1 58 18 68 28 --- http://fanf42.blogspot.com InterLDAP - http://interldap.org FederID - http://www.federid.org/ Open Source identities management and federation - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Tapestry JSONObject : no 'function' type, any workaround ?
ningdh wrote: Not aware of that, sorry. No problem, I didn't want to be harsh :) In my window component, I hack to replace double quote of all function to empty. JSONObject options= new JSONObject(); options.put(showEffect, TO_BE_REPLACE + this.showEffect+TO_BE_REPLACE); [...] It's exactly what I'm doing for now, I wanted to know if there were others simpler/nicer solution. Thank you very much for your help, I will stand with that for now. -- Francois Armand Etudes Développements J2EE Groupe Linagora - http://www.linagora.com Tél.: +33 (0)1 58 18 68 28 --- http://fanf42.blogspot.com InterLDAP - http://interldap.org FederID - http://www.federid.org/ Open Source identities management and federation - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Tapestry JSONObject : no 'function' type, any workaround ?
For json responses, i think it's good that the json is strict (i.e. no objects or callbacks allowed as values) For constructing js objects to be included in the html (to configure other js components) it's clear that JSONObject isn't the correct answer (json != js object) Probably the autocmplete mixin needs to use a 'new' JsObject class On Mon, Mar 9, 2009 at 4:10 PM, ningdh ningd...@gmail.com wrote: Not aware of that, sorry. In my window component, I hack to replace double quote of all function to empty. JSONObject options= new JSONObject(); options.put(showEffect, TO_BE_REPLACE + this.showEffect+TO_BE_REPLACE); getPageRenderSupport().addScript(%s = new Window(%s);, getUniqueId(), filterJsFunction(options.toString())); private String filterJsFunction(String jsonString) { // function begin jsonString = jsonString.replaceAll(\TO_BE_REPLACE, ); // function end jsonString = jsonString.replaceAll(TO_BE_REPLACE\, ); return jsonString; } Well, a bit stupid, but works. DH - Original Message - From: Francois Armand farm...@linagora.com To: Tapestry users users@tapestry.apache.org Sent: Monday, March 09, 2009 9:51 PM Subject: Re: Tapestry JSONObject : no 'function' type, any workaround ? ningdh wrote: toString method of JsonObject would double quote our value. One way is to create some data type extends jsonobject to encapsule your data and override the toString method. I haven't tried it yet. But JSONObject and JSONArray are final, that's not possible - it was my first plan. How can I workaround that ? -- Francois Armand Etudes Développements J2EE Groupe Linagora - http://www.linagora.com Tél.: +33 (0)1 58 18 68 28 --- http://fanf42.blogspot.com InterLDAP - http://interldap.org FederID - http://www.federid.org/ Open Source identities management and federation - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org -- Andreas Andreou - andy...@apache.org - http://blog.andyhot.gr Tapestry / Tacos developer Open Source / JEE Consulting - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Tapestry JSONObject : no 'function' type, any workaround ?
I have a solution :) I needed it to make my own autocomplete /** * */ package tapestryutil.mixins; /** Workarround to add raw content to JSON, like function references and such. * Number instances are not quoted and are trusted, so we use it.*/ final class JSONRaw extends Number { private final String rawText; JSONRaw(String rawText) { this.rawText = rawText; } @Override public double doubleValue() {return 0;} @Override public float floatValue() {return 0;} @Override public int intValue() {return 0;} @Override public long longValue() {return 0;} @Override public String toString() { return rawText; } } On Mon, Mar 9, 2009 at 3:33 PM, Andreas Andreou andy...@di.uoa.gr wrote: For json responses, i think it's good that the json is strict (i.e. no objects or callbacks allowed as values) For constructing js objects to be included in the html (to configure other js components) it's clear that JSONObject isn't the correct answer (json != js object) Probably the autocmplete mixin needs to use a 'new' JsObject class On Mon, Mar 9, 2009 at 4:10 PM, ningdh ningd...@gmail.com wrote: Not aware of that, sorry. In my window component, I hack to replace double quote of all function to empty. JSONObject options= new JSONObject(); options.put(showEffect, TO_BE_REPLACE + this.showEffect+TO_BE_REPLACE); getPageRenderSupport().addScript(%s = new Window(%s);, getUniqueId(), filterJsFunction(options.toString())); private String filterJsFunction(String jsonString) { // function begin jsonString = jsonString.replaceAll(\TO_BE_REPLACE, ); // function end jsonString = jsonString.replaceAll(TO_BE_REPLACE\, ); return jsonString; } Well, a bit stupid, but works. DH - Original Message - From: Francois Armand farm...@linagora.com To: Tapestry users users@tapestry.apache.org Sent: Monday, March 09, 2009 9:51 PM Subject: Re: Tapestry JSONObject : no 'function' type, any workaround ? ningdh wrote: toString method of JsonObject would double quote our value. One way is to create some data type extends jsonobject to encapsule your data and override the toString method. I haven't tried it yet. But JSONObject and JSONArray are final, that's not possible - it was my first plan. How can I workaround that ? -- Francois Armand Etudes Développements J2EE Groupe Linagora - http://www.linagora.com Tél.: +33 (0)1 58 18 68 28 --- http://fanf42.blogspot.com InterLDAP - http://interldap.org FederID - http://www.federid.org/ Open Source identities management and federation - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org -- Andreas Andreou - andy...@apache.org - http://blog.andyhot.gr Tapestry / Tacos developer Open Source / JEE Consulting - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Tapestry JSONObject : no 'function' type, any workaround ?
I love it ! Thank you, you made my day ! Davor Hrg wrote: I have a solution :) I needed it to make my own autocomplete /** * */ package tapestryutil.mixins; /** Workarround to add raw content to JSON, like function references and such. * Number instances are not quoted and are trusted, so we use it.*/ final class JSONRaw extends Number { private final String rawText; JSONRaw(String rawText) { this.rawText = rawText; } @Override public double doubleValue() {return 0;} @Override public float floatValue() {return 0;} @Override public int intValue() {return 0;} @Override public long longValue() {return 0;} @Override public String toString() { return rawText; } } On Mon, Mar 9, 2009 at 3:33 PM, Andreas Andreou andy...@di.uoa.gr wrote: For json responses, i think it's good that the json is strict (i.e. no objects or callbacks allowed as values) For constructing js objects to be included in the html (to configure other js components) it's clear that JSONObject isn't the correct answer (json != js object) Probably the autocmplete mixin needs to use a 'new' JsObject class On Mon, Mar 9, 2009 at 4:10 PM, ningdh ningd...@gmail.com wrote: Not aware of that, sorry. In my window component, I hack to replace double quote of all function to empty. JSONObject options= new JSONObject(); options.put(showEffect, TO_BE_REPLACE + this.showEffect+TO_BE_REPLACE); getPageRenderSupport().addScript(%s = new Window(%s);, getUniqueId(), filterJsFunction(options.toString())); private String filterJsFunction(String jsonString) { // function begin jsonString = jsonString.replaceAll(\TO_BE_REPLACE, ); // function end jsonString = jsonString.replaceAll(TO_BE_REPLACE\, ); return jsonString; } Well, a bit stupid, but works. DH - Original Message - From: Francois Armand farm...@linagora.com To: Tapestry users users@tapestry.apache.org Sent: Monday, March 09, 2009 9:51 PM Subject: Re: Tapestry JSONObject : no 'function' type, any workaround ? ningdh wrote: toString method of JsonObject would double quote our value. One way is to create some data type extends jsonobject to encapsule your data and override the toString method. I haven't tried it yet. But JSONObject and JSONArray are final, that's not possible - it was my first plan. How can I workaround that ? -- Francois Armand Etudes Développements J2EE Groupe Linagora - http://www.linagora.com Tél.: +33 (0)1 58 18 68 28 --- http://fanf42.blogspot.com InterLDAP - http://interldap.org FederID - http://www.federid.org/ Open Source identities management and federation - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org -- Andreas Andreou - andy...@apache.org - http://blog.andyhot.gr Tapestry / Tacos developer Open Source / JEE Consulting - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Tapestry JSONObject : no 'function' type, any workaround ?
Hello, I had the same annoying problem, but the patch works for me. But my question is: when will be a tapestry maintenance release which contains already this patch? btw, the same problem was solved in tapestry 4.1 long ago. rico On Fri, Mar 6, 2009 at 11:29 AM, Francois Armand farm...@linagora.comwrote: Hello, The JSONObject type doesn't have a javascript type that would allows to produce unquoted string value. I'm aware of the https://issues.apache.org/jira/browse/TAP5-39 issue, so my question is : anybody knows a good workaround for that ? Tanks, -- Francois Armand Etudes Développements J2EE Groupe Linagora - http://www.linagora.com Tél.: +33 (0)1 58 18 68 28 --- http://fanf42.blogspot.com InterLDAP - http://interldap.org FederID - http://www.federid.org/ Open Source identities management and federation - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Tapestry JSONObject : no 'function' type, any workaround ?
Rico Landefeld wrote: Hello, I had the same annoying problem, but the patch works for me. But my question is: when will be a tapestry maintenance release which contains already this patch? btw, the same problem was solved in tapestry 4.1 long ago. I would like - much prefer in fact - a workaround that does not imply to have my own version of T5... Already does that some times ago for an UTF-8 problem in URLs, and it's a mess to maintain (pom with non standard T5 repos, etc.). So, if someone has a less disruptive workaround, I will be glad to hear it :) (nonetheless, I keep in mind this solution...) -- Francois Armand Etudes Développements J2EE Groupe Linagora - http://www.linagora.com Tél.: +33 (0)1 58 18 68 28 --- http://fanf42.blogspot.com InterLDAP - http://interldap.org FederID - http://www.federid.org/ Open Source identities management and federation - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org