I trying to upgrade a small github Todo sample project (with java on server side) using TodoMVC ember sample on client side (upgrade based this topic)
The previous version with emberJs RC8 and ember-Data V013 is fully working fine. On server side, I have only modified todo’s attribute from underscored (is_completed) to camelized (isCompleted)
Currently, when receiving the server response, ember seems to not understand it and resend an post/put command, again and again… What I am doing wrong ??
todo.js:
Todos.Todo = DS.Model.extend({
title: DS.attr('string'),
isCompleted: DS.attr('boolean'),
saveWhenCompletedChanged: function () {
this.save();
}.observes('isCompleted')
});
app.js:
window.Todos = Ember.Application.create({
LOG_TRANSITIONS: true,
LOG_ACTIVE_GENERATION: true,
LOG_TRANSITIONS_INTERNAL: true
});
Todos.ApplicationAdapter = DS.RESTAdapter.extend({
namespace : 'todoSRV_NOSQL-V0.0.1/api/1/app',
beforeSend: function(xhr) { xhr.setRequestHeader('Accept', 'application/json'); }
});
CREATE: HTTP request sample:
POST http://localhost:8080/todoSRV_NOSQL-V0.0.1/api/1/app/todos/
associated request data: source {"todo":{"title":"aa","isCompleted":false}}
HTTP Response : (201 CREATED)
associated response data: {"todo":{"id":"5249502025c4a43c241b4ecf","title":"aa","isCompleted":"false"}}
UPDATE: HTTP request sample:
PUT http://localhost:8080/todoSRV_NOSQL-V0.0.1/api/1/app/todos/5249502025c4a43c241b4ecf
associated request data: source {"todo":{"title":"aa","isCompleted":true}}
HTTP Response : (200 OK)
associated response data: {"todo":{"id":"5249502025c4a43c241b4ecf","title":"aa","isCompleted":"true"}}
I’am applying “Ember REST Data’s Protocol” as described in this article, so I do not understand the trick.
Do you have any idea ? thanks !!