Announcement Announcement Module
No announcement yet.
"Select Entity" instruction not clear in field create? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • "Select Entity" instruction not clear in field create?


    I'm working through building a Roo project, using only the hints to guide me.

    By and large this is working out OK, although there are a couple of places where I think the hints could be a little clearer.

    Part of this is muddied by the fact that I'm using ctrl-space for everything, since tab-completion isn't quite working inside STS (per the Jira I filed mentioning the same).

    So the instructions say:

    To add a new field, type 'field' and then hit TAB. Be sure to select
    your entity and provide a legal Java field name. Use TAB to find an entity
    name, and '~' to refer to the top level package. Also remember to use TAB
    to access each mandatory argument for the command.
    So, I type field, and hit ctrl-space. I see --fieldName, and pick that. I type in a name for the field, and hit ctrl-space again, nothing. So I type -- and then ctrl-space, and see various field mods.

    But I don't see any option to pick my --entity flag, which is what I would expect based on how the other commands (e.g. webflow controllers) work.

    I noticed that if I type entity --name XX first, before I type 'field' it seems to select the entity...but it also says "Entity XX already exists", which is a little opposed to that + "Entity XX now selected" or something like that.

    From the tutorials, it looks like that is indeed the trick, but it's definitely not clear just from the hints.

    Make sense?

    Thanks! This is a lot of fun!


  • #2
    Hi Tim,

    what you are looking for is --class for the field commands. We have chosen to name this attribute class because you can use the field commands to introduce fields to any Java type not just entities (although most people would use it in conjunction with their existing entities).

    Remember, the --class attribute is not a mandatory command attribute because Roo will make a best effort attempt at guessing which class it should introduce your field to. So if you just created an entity in a previous command Roo will use that one unless you specify --class in your field command.




    • #3
      how does this work with jpa?

      I got a similar problem with roo 1.2.1

      I used

      entity jpa --class ~.domain.Foo

      to create an entity. After I added some fields and created another entity I wanted to select entity Foo again.

      How do I do this? there is no entity jpa --name or something.

      If I do

      entity jpa --class ~.domain.Foo

      again, it will recreate Foo deleting all my previously added fields.

      Can anybody give me a hint how to select my entity?


      • #4
        The docs seem to say:

        If you wish to add the field to a different target type you can specify the --class attribute as part of the field command which then allows you to tab complete to any type in your project.

        I thats what you want to do?




        • #5
          Thx Matt,

          now that you say it I see how it works. Will try it later



          • #6
            focus is the command

            You can use this command:
            focus --class ~.model.Customer to change back to the Customer entity, for example.