Announcement Announcement Module
No announcement yet.
Help needed with 'reference' field in petclinic sample Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help needed with 'reference' field in petclinic sample

    I ran the clinic.roo sample. Relevant portions having to do with 'reference' fields below:
    field string --fieldName firstName --sizeMin 3 --sizeMax 30 --class ~.domain.AbstractPerson
    field string --fieldName lastName --notNull --sizeMin 3 --sizeMax 30
    field string --fieldName address --notNull --sizeMax 50 --sizeMin 1
    field string --fieldName city --notNull --sizeMax 30
    field string --fieldName telephone --notNull
    field string --fieldName homePage --sizeMax 30
    field string --fieldName email --sizeMax 30 --sizeMin 6
    field date --fieldName birthDay --type java.util.Date --notNull
    field string --fieldName description --sizeMax 255 --class ~.domain.Visit
    field date --fieldName visitDate --type java.util.Date --notNull --past
    field reference --fieldName pet --type ~.domain.Pet --notNull
    field reference --fieldName vet --type ~.domain.Vet

    field boolean --fieldName sendReminders --notNull --primitive --class ~.domain.Pet
    field string --fieldName name --notNull --sizeMin 1
    field number --fieldName weight --type java.lang.Float --notNull --min 0
    When I create new visit, I get

    1. How do I modify the script so that only the names of the Pet (minus the weight) and the Vet (minus the Address) show up?
    2. Why is it that I don't get city, telephone, homePage, etc. for the Vet?

    I am new at Roo.
    This has been driving me nuts today.
    Thank you.

  • #2
    Just modify the toString() method of the


    • #3
      Overwriting toString() for business relevant usage in my opinion is a bad idea.

      My recommendation is, to implement a getDisplayName() method in the Entity classes were needed and then to change the corresponding tag, e.g.


      <form:select .... itemLabel="displayName" />

      This way, the toString() method is unchanged and can be used e.g. in logging messages.


      • #4
        How can the Roo script be modified to achieve the result? In other words, I'd like to able to make a change in the 'field reference' command. How would I go about doing that?