Uploaded image for project: 'Spring Roo'
  1. Spring Roo
  2. ROO-142

Problem with new controller automatic when you use the same Class Name

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.0.0.M2
    • Fix Version/s: 1.0.0.RC1
    • Component/s: None
    • Labels:
      None

      Description

      This has happened to me a couple of times during testing when I accidentally give the controller the same name as the domain class (or I forgot i wasn't using grails).

      roo>new persistent class jpa -name ~.domain.SomeClass
      Created SRC_MAIN_JAVA\org\stjude\ri\bwfp\domain\SomeClass.java
      Created SRC_MAIN_JAVA\org\stjude\ri\bwfp\domain\SomeClass_Roo_Entity.aj
      Created SRC_MAIN_JAVA\org\stjude\ri\bwfp\domain\SomeClass_Roo_ToString.aj
      Created SRC_MAIN_JAVA\org\stjude\ri\bwfp\domain\SomeClass_Roo_Configurable.aj

      roo> add field string -fieldName SomeField
      Managed SRC_MAIN_JAVA\org\stjude\ri\bwfp\domain\SomeClass.java
      Created SRC_MAIN_JAVA\org\stjude\ri\bwfp\domain\SomeClass_Roo_JavaBean.aj
      Managed SRC_MAIN_JAVA\org\stjude\ri\bwfp\domain\SomeClass_Roo_ToString.aj

      roo> new controller automatic -formBackingObject ~.domain.SomeClass -name ~.web.SomeClass
      Created SRC_MAIN_JAVA\org\stjude\ri\bwfp\web\SomeClass.java
      Managed SRC_MAIN_WEBAPP\WEB-INF\web.xml

      What happens is the generated controller looks like this

      package org.stjude.ri.bwfp.web;

      import org.springframework.roo.addon.web.mvc.controller.RooWebScaffold;
      import org.stjude.ri.bwfp.domain.SomeClass;
      import org.springframework.web.bind.annotation.RequestMapping;
      import org.springframework.stereotype.Controller;

      @RooWebScaffold(automaticallyMaintainView = true, formBackingObject = SomeClass.class)
      @RequestMapping("/someclass/**")
      @Controller
      public class SomeClass {
      }
      The class will not compile because the import conflicts with the class name but from the roo command line there is no indication of an error.

      It's an annoyance level issue and is easily fixed but could be common for users with previous grails experience.

      The new controller automatic command line needs to be able to detect if the provided classname in -name is the same as the provided classname in -formbackingobject and give an error, or be grails-like and append Controller to the generated class name.

        Attachments

          Activity

            People

            Assignee:
            sschmidt Stefan Schmidt
            Reporter:
            dalford Dan Alford
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: