我很难将我的 json 字符串提供给我的 dojo 增强型数据网格。现在基本上我有一个具有出生日期和国籍的人实体。人表上的国籍是外键。
我正在使用 spring 3.0,这是我用于生成 json 字符串的控制器逻辑。
uiModel.addAttribute("studentasJSON", new JSONSerializer().serialize(students));
//students is a list of Student objects
现在,如果我为一个学生打印出 json 字符串,我们就有了这个。
[{"class":"tt.edu.sbcs.model.Student","comment":null, "dateOfBirth":{"class":"java.util.GregorianCalendar","firstDayOfWeek":1,"gregorianChange" :-12219292800000,"lenient":true,"minimalDaysInFirstWeek":1,"time":1069041600000,"timeInMillis":1069041600000,"timeZone":{"DSTSavings":0,"ID":"America/La_Paz","类":"sun.util.calendar.ZoneInfo","dirty":false,"displayName":"玻利维亚时间","lastRuleInstance":null,"rawOffset":-14400000}} ,"ethnicOrigin":null," firstName":"Goat","gender":"Male","id":5487,"lastName":"Dog","legacyID":null,"maritalStatus":"Single", "nationality":{"class":"tt.edu.sbcs.model.Country","code":"BB","id":1,"name ":"巴巴多斯","版本":262},"nativeLanguage":null,"otherName":"","photo":null,"religion":null,"title":{"class":"tt.edu.sbcs.model.Title","id" :1,"name":"先生","version":0},"uniqueIdNumber":null,"version":0}]
这就是复杂的地方。dojo 增强网格需要"dateOfBirth":"2003-11-17"。同样,“国籍”:“巴巴多斯”而不是完全序列化的对象。但是,http: //dojotoolkit.org/reference-guide/dojo/store.html 谈到了查询现有数据存储,但不太清楚如何使用它。有人可以建议吗?
我在http://forum.springsource.org/showthread.php?103331-Best-practices-with-Spring-Roo-JSON-and-Ajax上看到他们使用 dojo 增强网格的查询属性来查询字符串. 就像是
<table dojoType="dojox.grid.DataGrid"
jsid="grid" id="grid" class="grid" autoHeight="15" noDataMessage="Sorry, there is no data available."
store="jsonStore" query="{ name: '*' }" rowsPerPage="20" rowSelector="20px">
有人可以就查询属性的使用提出建议。在生成字符串后对其进行操作是不切实际的,因为在我的系统中会有数千个元组和与任意实体的链接。