• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Deep ERRest knowledge? - I'm adding an ERXJSONPRestWriter
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Deep ERRest knowledge? - I'm adding an ERXJSONPRestWriter


  • Subject: Re: Deep ERRest knowledge? - I'm adding an ERXJSONPRestWriter
  • From: Pascal Robert <email@hidden>
  • Date: Fri, 13 Jul 2012 20:01:41 -0400

Did you push your changes to your fork of Wonder on GitHub?

>
> indeed!
>
> overkill!
>
> and I HATE killing overs!
>
> but when you say "ERRest will look at the request" -- isn't that what I'm trying to do?
>
> or I should say, how should I bet implement this callback query argument is present?
>
> aside from setting up a few keys for jsonp, at this time, I simply set the response header to javascript and I "can" the callback method name.
>
> you'll see I had written in some code which I figured would get the requested callback name and send via userInfo, which is obviously not needed.
>
> so, can I somehow access the request from here? or how do I otherwise look at the request at the right time and do the right thing?
>
>
>
>
>
>
> public class ERXJSONPRestWriter extends ERXJSONRestWriter {
>
> 	public void appendHeadersToResponse(ERXRestRequestNode node, IERXRestResponse response, ERXRestContext context) {
> 		response.setHeader("text/javascript;charset=UTF-8", "Content-Type");
> 	}
>
> 	public void appendToResponse(ERXRestRequestNode node, IERXRestResponse response, ERXRestFormat.Delegate delegate, ERXRestContext context) {
> 		String callbackName = (String) context.userInfoForKey("callback");
>
> 		if (callbackName != null)
> 			response.appendContentString(callbackName + "(");
> 		else
> 			response.appendContentString("callback(");
>
>
> 		node = processNode(node);
> 		if (node != null) {
> 			node._removeRedundantTypes();
> 		}
>
> 		appendHeadersToResponse(node, response, context);
> 		Object object = node.toJavaCollection(delegate);
> 		if (object == null) {
> 			response.appendContentString("undefined");
> 		}
> 		else if (ERXRestUtils.isPrimitive(object)) {
> 			response.appendContentString(String.valueOf(object));
> 		}
> 		else {
> 			response.appendContentString(JSONSerializer.toJSON(object, configWithContext(context)).toString());
> 		}
>
> 		response.appendContentString(");");
> 	}
>
> }
>
>
>
> On Jul 13, 2012, at 7:50 PM, Pascal Robert <email@hidden> wrote:
>
>> That's overkill :-) It should be implemented like the window.name transport, e.g. ERRest will look at the request to see if a "callback" query argument was passed, and if yes, wrap it.
>>
>>> I'm adding an ERXJSONPRestWriter in Wonder, to support JSONP in ERRest
>>>
>>> so, like getting any ERRest format request, you can now also get jsonp:
>>>
>>> /ra/Person/306.jsonp
>>>
>>> so far, so good
>>>
>>> the spec. calls for an optional callback method name, requested on the URL
>>>
>>> /ra/Person/306.jsonp?callback=parseResponse
>>>
>>> or, it seems less commonly:
>>>
>>> /ra/Person/306.jsonp?jsonp=parseResponse
>>>
>>> The RestWriter didn't have access to the originating request, so I figured I'd send in the method name through the userInfo dictionary and I'd be able to pick that up in the writer?
>>>
>>> So, I thought I'd write something like a ERXJSONPRestResponseWriter?
>>>
>>> But that's not really what I should do? I can see I'm onto the wrong track here -
>>>
>>> Does anyone know the internals of ERRest well enough to help guide me just a bit here?
>>>
>>> I suspect if I can get my head around the design, I can check in this stuff in case anyone needs cross origin or jsonp support for whatever reason.
>>>
>>> Thanks for any advice!
>>>
>>>
>>>
>>> _______________________________________________
>>> Do not post admin requests to the list. They will be ignored.
>>> Webobjects-dev mailing list      (email@hidden)
>>> Help/Unsubscribe/Update your Subscription:
>>>
>>> This email sent to email@hidden
>>
>


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Deep ERRest knowledge? - I'm adding an ERXJSONPRestWriter
      • From: Jesse Tayler <email@hidden>
References: 
 >Deep ERRest knowledge? - I'm adding an ERXJSONPRestWriter (From: Jesse Tayler <email@hidden>)
 >Re: Deep ERRest knowledge? - I'm adding an ERXJSONPRestWriter (From: Pascal Robert <email@hidden>)
 >Re: Deep ERRest knowledge? - I'm adding an ERXJSONPRestWriter (From: Jesse Tayler <email@hidden>)

  • Prev by Date: Re: Deep ERRest knowledge? - I'm adding an ERXJSONPRestWriter
  • Next by Date: Re: Deep ERRest knowledge? - I'm adding an ERXJSONPRestWriter
  • Previous by thread: Re: Deep ERRest knowledge? - I'm adding an ERXJSONPRestWriter
  • Next by thread: Re: Deep ERRest knowledge? - I'm adding an ERXJSONPRestWriter
  • Index(es):
    • Date
    • Thread