Announcement Announcement Module
Collapse
No announcement yet.
ManyToOne web scaffold failing Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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:
    <field:select field="licensee" id="c_com_springtest_domain_AppUser_licensee" itemValue="id" items="${licensees}" path="/licensees" required="true" z="BBd/rBG6JoDcVEw/wePU1jnlYj8="/>
    but how does it actually work? What might I be missing?

  • #2
    anyone? There's too much magic between the time the http 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.

    Comment


    • #3
      There should be a ConversionService available in your Web application (generated and managed by Roo). See http://static.springsource.org/sprin...-1.1.1.RELEASE

      Which version of Roo are you using?

      -Stefan

      Comment


      • #4
        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:

        <mvc:annotation-driven/>

        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.

        Comment


        • #5
          I'm using 1.1.0.RELEASE

          Comment


          • #6
            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.

            Comment


            • #7
              Originally posted by Stefan Schmidt View Post
              There should be a ConversionService available in your Web application (generated and managed by Roo). See http://static.springsource.org/sprin...-1.1.1.RELEASE
              I'd also be interested in how the conversion works in Roo. AFAICS, the Roo-generated Converters handle entity -> 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

              Comment


              • #8
                this post describes the issue I'm having:
                http://forum.springsource.org/showthread.php?t=81238

                I just need to figure out how to manually configure the converters.

                Comment


                • #9
                  well, I'm not sure how to fix this. I need "<mvc:annotation-driven/>" 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.

                  Comment


                  • #10
                    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 url 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);
                        }
                        
                    }

                    Comment

                    Working...
                    X