|
|
ManyToOne web scaffold failing
I have a simple OneToMany relationship between two entities (Licensee has many AppUsers) that I have created web scaffolds for. When I try to save an AppUser with a reference to a Licensee, I get:
Code:
Failed to convert property value of type java.lang.String to required type Licensee for property licensee; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [Licensee] for property licensee: no matching editors or conversion strategy found
I created a scaled down new project with the same two entities and it works fine. I've been comparing all the relevant files between the two projects and I can't see any differences. In create.jspx, I see this:Code:
lt;field:select field=quot;licenseequot; id=quot;c_com_springtest_domain_AppUser_licenseequot; itemValue=quot;idquot; items=quot;${licensees}quot; path=quot;/licenseesquot; required=quot;truequot; z=quot;BBd/rBG6JoDcVEw/wePU1jnlYj8=quot;/gt;
but how does it actually work? What might I be missing?
anyone? There's too much magic between the time the from request is made and my controller is called. Normally I'd expect a PropertyEditor to handle converting a String to an object here, but there aren't any signs of PropertyEditors in the roo generated code.
There should be a ConversionService available in your Web application (generated and managed by Roo). See sprin...-1.1.1.RELEASE
Which version of Roo are you using?
-Stefan
I figured it out. As part of this project, I was also creating an Xstream based REST api. When I added the Xstream OXM config to webmvc-config.xml, I moved this line:
lt;mvc:annotation-driven/gt;
down in the config. This was to prevent spring from using the default for marshalling, JAXB. As soon as I moved this back up to the top of the config, this binding problem went away.
I'm using 1.1.0.RELEASE
unfortunately, I can't seem to get my webmvc-config.xml order set up correctly to both use XStream and get the roo converters working.
Originally Posted by Stefan SchmidtThere should be a ConversionService available in your Web application (generated and managed by Roo). See sprin...-1.1.1.RELEASE
I'd also be interested in how the conversion works in Roo. AFAICS, the Roo-generated Converters handle entity -gt; String conversion, but not the other way around.
That said, having the central ConversionService and being able to customize it is one of my favourite improvements in 1.1.1 .
Regards, --Christopher
this post describes the issue I'm having:
showthread.php?t=81238
I just need to figure out how to manually configure the converters.
well, I'm not sure how to fix this. I need quot;lt;mvc:annotation-driven/gt;quot; for roo conversions to work, which creates a AnnotationMethodHandlerAdapter behind the scenes I believe. But I need to wire up my own AnnotationMethodHandlerAdapter for Xstream. I'm thinking of using two DispatcherSerlvets and two configs since I was thinking about making this two separate projects from the start. This would help avoid future problems with roo as I could hopefully let the too commands do their thing and not have to customize so much.
Ended up with two configs which I think ends up being a good way to split an admin app from the consumer facing app. No more worrying about a change to the web context config breaking something roo needs. I wanted to use spring security for both paths, so I wanted to pass the DispatcherServlet ucl path on (ie /admin) to the handlers so I could use spring security on that path. To do that I introduced a bean to change the handler config:Code:
public class SpringStartupConfig {
@Autowired private DefaultAnnotationHandlerMapping defaultAnnotationHandlerMapping; public void init() { this.defaultAnnotationHandlerMapping.setAlwaysUseFullPath(true); }
} |
|