You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by bhorvat <ho...@gmail.com> on 2012/10/20 22:12:44 UTC

Passing a javascript function in JSONArray or JSONObject

How can I do this? If i try to put a function it returns surrounded with ""
for example tapestry would generate

    {
      "id" : "textfield_3",
      "paramName" : "t:input",
      "url" :
"http://localhost:8080/assets.assetdetails.componentdata.textfield_0:autocomplete",
      "options" : {
        "select" : "function (event, ui) {alert('This is the call back
function');}"
      }
    }

So how can I write  "function (event, ui) {alert('This is the call back
function');}" with out ""
here is my Java Code

    public JSONObject getAutoParams() {
        return new JSONObject("select", "function (event, ui) {alert('This
is the call back function');}");
    }



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Passing-a-javascript-function-in-JSONArray-or-JSONObject-tp5717095.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: Passing a javascript function in JSONArray or JSONObject

Posted by bhorvat <ho...@gmail.com>.
I figured it out

Tnx Howard for pointing me in right direction.

For those interested here is what did the trick for me

    public JSONObject getAutoParams() {
        JSONObject params = new JSONObject();
        params.put("select", new JSONLiteral("function (event, ui)
{alert('This is the call back function');}"));
        return params;
    }

and I pass this as the options parameter in the autocomplete component/mixin



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Passing-a-javascript-function-in-JSONArray-or-JSONObject-tp5717095p5717099.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: Passing a javascript function in JSONArray or JSONObject

Posted by bhorvat <ho...@gmail.com>.
I have tried to use JSONString such as 

                    JSONString string = new JSONLiteral(" select: function
(event, ui) { alert('test') }");

however the problem is that I can not pass that to the tapestry
autocomponent since it only accesspts JSONObject and this is not a valid
JSONObject.

Any idea who can I pass the function (whit JSONString) in tapestry



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Passing-a-javascript-function-in-JSONArray-or-JSONObject-tp5717095p5717098.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: Passing a javascript function in JSONArray or JSONObject

Posted by bhorvat <ho...@gmail.com>.
Hi Howard, 

Can I please ask you to share a link as I couldnt find anything related to
the Java Fox Jsonstring.

tnx for help



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Passing-a-javascript-function-in-JSONArray-or-JSONObject-tp5717095p5717097.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: Passing a javascript function in JSONArray or JSONObject

Posted by Howard Lewis Ship <hl...@gmail.com>.
Ths is possible but not exactly json. See java fox about Jsonstring.
On Saturday, October 20, 2012, bhorvat wrote:

> How can I do this? If i try to put a function it returns surrounded with ""
> for example tapestry would generate
>
>     {
>       "id" : "textfield_3",
>       "paramName" : "t:input",
>       "url" :
> "
> http://localhost:8080/assets.assetdetails.componentdata.textfield_0:autocomplete
> ",
>       "options" : {
>         "select" : "function (event, ui) {alert('This is the call back
> function');}"
>       }
>     }
>
> So how can I write  "function (event, ui) {alert('This is the call back
> function');}" with out ""
> here is my Java Code
>
>     public JSONObject getAutoParams() {
>         return new JSONObject("select", "function (event, ui) {alert('This
> is the call back function');}");
>     }
>
>
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/Passing-a-javascript-function-in-JSONArray-or-JSONObject-tp5717095.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org<javascript:;>
> For additional commands, e-mail: users-help@tapestry.apache.org<javascript:;>
>
>

-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com