Re: Another dumb ERRest question

2011-03-29 Thread Farrukh Ijaz
Hi Andrew,

I think you shouldn't return a filtered response when you're deleting the 
object. Your response should indicate your operation was successful or not 
based on the editingContext().saveChanges() out come.

response(entity, showFilter()) should be used for GET (fetch / select) and 
optionally in PUT (insert) and POST (update).

Farrukh

On 2011-03-28, at 10:36 PM, Andrew Kinnie wrote:

 I am again working on my ERRest based push notification server, and am having 
 an issue with the framework.
 
 I am using a version of Wonder from last week (the 5.4 branch), in eclipse 
 3.6 using a MySQL database on the development machine.
 
 I looked at the example app, and copied the key functions from it (after 
 wasting time trying to over-think it for a while going back to the easy 
 method).
 
 I can add a new object, it stores it in the database, but if I then attempt 
 to delete it using the code:
 
   @Override
   public WOActionResults destroyAction() throws Throwable {
   NotificationType type = notificationType();
   type.delete();
   editingContext().saveChanges();
   return response(type, showFilter());
   }
 
 The type gets the delete message, saveChanges deletes the row in the 
 database (the EO_PK_TABLE still shows it's pk as the current pk, which I 
 gather is normal) but then the returned method 
 
 response(type, showFilter());
 
 crashes with an NPE deep in the guts of ERRest:
 
   requestNode._fillInWithObjectAndFilter(obj, classDescription, 
 keyFilter, delegate, new HashSetObject());
 
 This is called in ERXRestRequestNode.java.  It appears (though I'm not 
 completely sure) that the method is asking for the old object it just 
 deleted, and there isn't one, because it just deleted it.  However, I copied 
 this code directly from the example, so something somewhere is going wrong 
 that doesn't go wrong in the example app.
 
 So, I can avoid all this by just returning null, as the user will not 
 actually need to get a response, but I thought I'd ask the question, what 
 should I be doing here, and what might be going wrong?
 
 Andrew
 ___
 Do not post admin requests to the list. They will be ignored.
 Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/webobjects-dev/farrukh.ijaz%40fuegodigitalmedia.com
 
 This email sent to farrukh.i...@fuegodigitalmedia.com

 ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Another dumb ERRest question

2011-03-29 Thread Andrew Kinnie
Well, that certainly seemed logical to me (and was my first guess), but I based 
my code on the example app, which does exactly what I did.  Oddly, when I ran 
the example app, and deleted based on a plist I got the same result I do in 
mine (except with quotes around it) and if I did the same thing via json, I got 
a message that there is no object with that id.  So apparently the example app 
does do much useful either.

For now I will return null.  We are not going to do much deleting via this 
interface regardless.

Thanks


On Mar 29, 2011, at 4:15 AM, Farrukh Ijaz wrote:

 Hi Andrew,
 
 I think you shouldn't return a filtered response when you're deleting the 
 object. Your response should indicate your operation was successful or not 
 based on the editingContext().saveChanges() out come.
 
 response(entity, showFilter()) should be used for GET (fetch / select) and 
 optionally in PUT (insert) and POST (update).
 
 Farrukh
 ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Another dumb ERRest question

2011-03-28 Thread Andrew Kinnie
I am again working on my ERRest based push notification server, and am having 
an issue with the framework.

I am using a version of Wonder from last week (the 5.4 branch), in eclipse 3.6 
using a MySQL database on the development machine.

I looked at the example app, and copied the key functions from it (after 
wasting time trying to over-think it for a while going back to the easy method).

I can add a new object, it stores it in the database, but if I then attempt to 
delete it using the code:

@Override
public WOActionResults destroyAction() throws Throwable {
NotificationType type = notificationType();
type.delete();
editingContext().saveChanges();
return response(type, showFilter());
}

The type gets the delete message, saveChanges deletes the row in the database 
(the EO_PK_TABLE still shows it's pk as the current pk, which I gather is 
normal) but then the returned method 

response(type, showFilter());

crashes with an NPE deep in the guts of ERRest:

requestNode._fillInWithObjectAndFilter(obj, classDescription, 
keyFilter, delegate, new HashSetObject());

This is called in ERXRestRequestNode.java.  It appears (though I'm not 
completely sure) that the method is asking for the old object it just deleted, 
and there isn't one, because it just deleted it.  However, I copied this code 
directly from the example, so something somewhere is going wrong that doesn't 
go wrong in the example app.

So, I can avoid all this by just returning null, as the user will not actually 
need to get a response, but I thought I'd ask the question, what should I be 
doing here, and what might be going wrong?

Andrew
 ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com