Announcement Announcement Module
Collapse
No announcement yet.
Adding/changing methods in a scaffolded controllers Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Adding/changing methods in a scaffolded controllers

    I have noticed that it's impossible (for me) to add a new method in a scaffolded controller (in the .java part) without hiding all the .aj methods (CRUD, finders...)
    Same thing if I need to modify one of the generated (.aj) method by moving it in the .java file. The .java "hides" .aj at runtime ??
    So, if I want to add/change one generated method, i have to copy ALL the .aj in the java file ?
    I probably miss something, because it's no what I understood in the doc or threads of this forum ! What's wrong in my understanding ??
    Thanks !

  • #2
    Are you referring to Eclipse aspectj refactoring? I have been able to "push in" a single method. If I remember correctly, I had to highlight the method name (and only the method name), then right-click on the highlighted method name and choose "aspectj refactoring->push in".

    Comment


    • #3
      By default, Pizza_Roo_Controller.aj will contain these methods (assuming no finders have been added):

      Code:
      create(Pizza, BindingResult, ModelMap)
      createForm(ModelMap)
      delete(Long, Integer, Integer)
      list(Integer, Integer, ModelMap)
      show(Long, ModelMap)
      update(Pizza, BindingResult, ModelMap)
      updateForm(Long, ModelMap)
      ... and PizzaController.java will contain none.

      If you copy one of the above methods (for example "show") from the .aj file to the .java file and run Roo, Roo will delete the method from the .aj file because you've overridden it. All the other methods in the .aj file will remain untouched. Is that not what's happening for you?

      Comment


      • #4
        Originally posted by mikej View Post
        Are you referring to Eclipse aspectj refactoring? I have been able to "push in" a single method. If I remember correctly, I had to highlight the method name (and only the method name), then right-click on the highlighted method name and choose "aspectj refactoring->push in".
        I didn't know that trick; I've always just copied-and-pasted it and fixed the compile errors. I don't have "aspectj refactoring" in my context menu, but when I tried "Refactor -> Push In..." just now in STS 2.3.0, I got this error:

        Rebuild project. No crosscutting model available.
        Other people have reported this error, but none of the alleged fixes work for me (e.g. my M2_REPO is already set). Does it work for anyone else using STS 2.3.0? It's no big deal; as I said above, you can always push methods in manually.

        Comment


        • #5
          Actually now I get the same error you're reporting. (It's been a while since I tried using the aspectj refactoring in eclipse, so I don't know when it stopped working.)

          The other problem was that if I did not actually highlight the method name (but just right-clicked it) Eclipse would only give me the choice to push in ALL methods from the file. I thought maybe that's what the poster was asking about.

          Comment


          • #6
            well.. I'm using STS, but unable to open the .aj files;
            1- to modify a CRUD method, I cut and paste it from an external editor in .java
            2- to add one method, I can do it directly inside STS, and immediatly at run-time the CRUD methods (and all methods from .aj) "disappear" and result in "GET not implemented.
            Reading your responses, I'll try to work outside STS to see if there is any difference

            Comment


            • #7
              Did you manage to get this working? Did you try the latest AJDT version?

              Comment

              Working...
              X