users@jersey.java.net

[Jersey] Re: JsonP without using JSONWithPadding?

From: <ed_at_anuff.com>
Date: Mon, 21 Nov 2011 10:46:34 -0800 (PST)

My web services I'm basically returning POJO's from my methods and I'm
setting com.sun.jersey.api.json.POJOMappingFeature=true. Currently, to do
JSONP, I had to do the following:

1) change the produces to:

    @Produces({ MediaType.APPLICATION_JSON, "application/javascript",
                "application/x-javascript", "text/ecmascript",
                "application/ecmascript", "text/jscript" })

2) change every method signature to include:

    @QueryParam("callback") @DefaultValue("callback") String callback

3) change every return type of every method to JSONWithPadding (from my own
return type of ApiResponse).

4) wrap the return type at the end of every method:

                return new JSONWithPadding(response, callback);

I may be missing something and there might be an easier way, but it would be
nice of all of that boilerplate wasn't necessary. I did try to write my own
provider based on the JSONWithPaddingProvider but didn't get very far.


--
View this message in context: http://jersey.576304.n2.nabble.com/JsonP-without-using-JSONWithPadding-tp7015082p7017507.html
Sent from the Jersey mailing list archive at Nabble.com.