kazu2012 / persevere-framework

Automatically exported from code.google.com/p/persevere-framework
0 stars 0 forks source link

REST handlers: post() not being called #205

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create a Class.
2. Define a post() method (I tried defining this as an instance method on the 
class prototype and 
as a static method on the class, both) containing the line alert("hi, post()");
3. Define a put() method on the class prototype containing the line alert("hi 
put()");
4. Make a POST request to create a new instance of your class.

What is the expected output? What do you see instead?

I expect to see "hi post()" in the console. Instead I see "hi put()".

What version of the product are you using? On what operating system?

r503, java version 1.6, linux

Please provide any additional information below.

Original issue reported on code.google.com by Micha.Ni...@gmail.com on 12 Jun 2009 at 12:58

GoogleCodeExporter commented 8 years ago
Fixed the put handler being called incorrectly on creation of objects, and 
incorrect 
handling of post calls.
Note that the post handler is not called on the class, it must be on the query 
prototype. 
Query.prototype.post = function(postedObject){
  console.log("post called");
  return postedObject;
};

Original comment by kris...@gmail.com on 26 Jun 2009 at 9:20

GoogleCodeExporter commented 8 years ago
Also, you can create an initialize function for when an object is created (and 
use 
onSave after all updates). I would recommend sticking to setting 
initialize/onSave 
handlers for most use cases.

Original comment by kris...@gmail.com on 26 Jun 2009 at 9:22