Hi.. sencha forum member i need one help from you.
I am developing an application in which I am interacting with the database using proxy api: create, read, update, destroy.
I am done to read the data from the server side. Now I want to create new record by passing data from the view to my server side controller.
When i click the save button my create api calls and execute POST that interact of the controller.
after clicking the save button my json data submitted is
Code:
| JSON
|
|
|
|
| taskdata |
[Object { Name="New task", StartDate="2010-02-13T05:30:00", EndDate="2010-02-23T05:30:00", more...}] |
| 0 |
Object { Name="New task", StartDate="2010-02-13T05:30:00", EndDate="2010-02-23T05:30:00", more...} |
| Duration |
1 |
| DurationUnit |
"d" |
| EndDate |
"2010-02-23T05:30:00" |
| Id |
null |
| ManuallyScheduled |
false |
| Name |
"New task" |
| PercentDone |
0 |
| Priority |
1 |
| StartDate |
"2010-02-13T05:30:00" |
| checked |
null |
| depth |
1 |
| index |
2 |
| parentId |
null |
|
| Source |
| {"taskdata":[{"Id":null,"Name":"New task","StartDate":"2010-02-13T05:30:00","EndDate":"2010-02-23T05:30:00","Duration":1,"DurationUnit":"d","PercentDone":0,"ManuallyScheduled":false,"Priority":1,"parentId":null,"index":2,"depth":1,"checked":null}]} |
on the server side when i print the data which i had passed it gives me
Code:
{ taskdata = [{
Id = null,
Name = New task,
StartDate = 2010 - 02 - 13T05: 30: 00,
EndDate = 2010 - 02 - 23T05: 30: 00,
Duration = 1,
DurationUnit = d,
PercentDone = 0,
ManuallyScheduled = false,
Priority = 1,
parentId = null,
index = 2,
depth = 1,
checked = null
}]
}
what mistake i am making that my json data is full converted to Array. I want my data to be in json format only.
I am using spring for the server side beans management and the controller to make my work done.
my function that gives me above output is
Code:
@RequestMapping(value= "/task/CreateTask.action") public @ResponseBody Map<String, ? extends Object> createTask(@RequestBody Map<String, Object> taskdata) throws Exception {
try {
System.out.println("INSIDE CREATE TASK :"+taskdata);
List<Task> tasks = ganttService.createTask(taskdata);
return getMapTask(tasks);
}catch(Exception e) {
return getModelMapError("Error in creating Task");
}
}
Yogendra Singh
Sr. Programmer
Kintudesigns.com