Hi, this is a bit of a follow-up on http://forum.springsource.org/showth... gViewResolver
While I'm waiting to find out how to do this via GWT, I'm doing my temperaments app with "classic" Roo, here's my app that's just started:
In webmvc-config.xml I've added:Code:project --topLevelPackage com.saers.temperamentsapp --projectName TemperamentsApp --java 6 --template STANDARD_PROJECT persistence setup --provider HIBERNATE --database HYPERSONIC_IN_MEMORY entity --class ~.domain.server.AppUser --testAutomatically field string --fieldName username --notNull --sizeMin 3 field string --fieldName passwordHash --notNull entity --class ~.domain.server.Device --testAutomatically field string --fieldName UUID field string --fieldName name field boolean --fieldName willSync field date --fieldName lastSync --type java.util.Date field set --class ~.domain.server.AppUser --fieldName devices --element ~.domain.server.Device perform tests controller all --package ~.web security setup perform eclipse
and in pom.xml I've addedCode:<bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver"> <property name="mediaTypes"> <map> <entry key="json" value="application/json"/> </map> </property> <property name="defaultViews"> <list> <bean class="org.springframework.web.servlet.view.json.MappingJacksonJsonView" /> </list> </property> </bean>
When I launch my app and create two devices for the AppUser and display my AppUser, I get the following JSON:Code:<dependency> <groupId>org.codehaus.jackson</groupId> <artifactId>jackson-mapper-lgpl</artifactId> <version>1.5.3</version> </dependency> <dependency> <groupId>org.codehaus.jackson</groupId> <artifactId>jackson-core-lgpl</artifactId> <version>1.5.3</version> </dependency>
Two questions:Code:{ "appuser" : { "devices" : [ { "deviceUUID" : "ZZ", "id" : 2, "lastSync" : null, "name" : "WW", "version" : 0, "willSync" : true }, { "deviceUUID" : "XX", "id" : 1, "lastSync" : null, "name" : "YY", "version" : 0, "willSync" : true } ], "id" : 1, "passwordHash" : "njs", "username" : "njs", "version" : 0 }, "devices" : [ { "deviceUUID" : "XX", "id" : 1, "lastSync" : null, "name" : "YY", "version" : 0, "willSync" : true }, { "deviceUUID" : "ZZ", "id" : 2, "lastSync" : null, "name" : "WW", "version" : 0, "willSync" : true } ] }
- I don't want to display some properties of my beans, for example passwordHash and version. What should I do to hide them away from my view?
- Why is the set "devices" displayed twice, and what should I do to make this correctly just once as a part of the appuser?
Cheers
Nik


Reply With Quote
.
