Hi Friends...
i'm trying to build a simple application by using SpringMVC + Dojo-Grid + JPA + JsonLib.. but i'm stuck.. because i'm new learn about Dojo JSON app..
I don't know how to bind data from JPA Entities (which Serialized by JsonSerializer class)...
this is my JPA entity :
this is my controller :Code:public class Major{ private Long id; private String name; private Long version; //getter n setter }
and the result from JsonSerializer is :Code:@Controller public class JSON1 { @Autowired private MajorService majorService; @RequestMapping("/json1.htm") public ModelAndView show(HttpServletRequest request, HttpServletResponse response) throws Exception{ List<Major> majors=majorService.getAll(); Object o =new JsonSerializer().serialize(majors); return new ModelAndView("json1", "data", o); } }
now.. how to bind it in Dojo Grid?..Code:[{"~unique-id~":"0","id":1,"class":"com.example.entities.Major","name":"First Major","version":10},{"~unique-id~":"1","id":1,"class":"com.latihan.entities.Major","name":"Second Major","version":5}]
i've tried this.. but it's still doesn't work..
this is my javascript's function :
Code:var view1 = { cells: [ [ {name: 'Id', field: "id"}, {name: 'Name', field: "name"}, {name: 'Version',field: "version"} ] ] }; // a grid layout is an array of views. var layout = [ view1 ]; // the model will contain the data to be displayed in the view model = new dojox.grid.data.Objects([{key: "id"}, {key: "nama"},{key: "version"}]); function loadTable(page){ start = page * batchSize; var targetURL = "/WebApplication/json1.htm"; dojo.xhrGet({ url: targetURL, handleAs: "json", load: handleResponse, error: handleError }); } function handleResponse(responseObject, ioArgs){ model.setData(responseObject); }Please help me..Code:<div id="grid" dojoType="dojox.Grid" model="model" structure="layout"></div>
Thanks in advance..![]()



Reply With Quote
