Announcement Announcement Module
Collapse
No announcement yet.
Show ID field (Primary Key) in list.jspx Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Show ID field (Primary Key) in list.jspx

    I want to be able to show the id field (a primary key) of each entry in list.jspx and subsequently allow the user to enter their own id in create.jspx (down the road). Is this possible?

  • #2
    The id field is not show on direct engineer (make with entity and field commands) because value is auto generated.

    You can push-in the id property to your java class and remove the generated value annotation:

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id")
    private Long id;
    Regards !

    Comment


    • #3
      I have the following for a very simple test. This is in test.java. Roo did automatically delete what is in test_roo_jpa_entity.java and the code in DB_managed. However when I run it on the server only the name is shown in list.jspx, still no ID field.

      @RooJavaBean
      @RooToString
      @RooJpaActiveRecord(versionField = "", table = "test")
      @RooDbManaged(automaticallyDelete = true)
      public class Test {

      @Id
      @Column(name = "testId")
      private Integer testId;

      @Column(name = "name", length = 30)
      private String name;

      //Getter & Setter for testId
      public Integer getTestId() {
      return this.testId;
      }

      public void setTestId(Integer testId) {
      this.testId = testId;
      }

      //Getter & Setter for Name
      public String getName() {
      return name;
      }

      public void setName(String name) {
      this.name = name;
      }
      }
      Any further advice? Thank you very much.

      Comment


      • #4
        You have to add the id-column manually to list.jspx

        e.g.

        <table:column id="c_com_foo_bar_id" property="id" z="-1"/>

        Comment


        • #5
          Originally posted by spgmx View Post
          You have to add the id-column manually to list.jspx

          e.g.

          <table:column id="c_com_foo_bar_id" property="id" z="-1"/>
          With this solution, id value will be already auto generated.

          Comment


          • #6
            Originally posted by mmartinez View Post
            With this solution, id value will be already auto generated.
            It's just a new column in the HTML-table. Has nothing to do with generated keys or not. The table even doesn't care if it is an @Id field or not. Just a bean property.

            Comment


            • #7
              When I type the following into list.jspx

              <table:column id="c_com_mtc_test_Test_testId" property="testId" z="-1"/>
              I get an internal error. and that "No message found under code 'label_com_mtc_test_test_testid' for locale 'en_US'". The id field I am trying to show is called testId.
              Last edited by ericmc; Jul 2nd, 2012, 08:08 AM.

              Comment


              • #8
                You have to add the message key 'label_com_mtc_test_test_testid' in your application.properties

                Comment


                • #9
                  Originally posted by spgmx View Post
                  It's just a new column in the HTML-table. Has nothing to do with generated keys or not. The table even doesn't care if it is an @Id field or not. Just a bean property.
                  This is to allow the user to enter their own id in create.jspx, this is a requirement of ericmc at first post message.

                  Comment

                  Working...
                  X