2

I have the following problem: I want to order the columns of a DomainObject in order to have the most important information first i.e. left. Therefor I used the @MemberOrder Annotaion, but this does not work. I have NO layout.xml so no options are overwritten.

Here is some example code of my domain object:

 @PersistenceCapable(identityType = IdentityType.DATASTORE, table = "jobs")
 @Extension(vendorName = "datanucleus", key = "datastore", value = "store-email")
 @Inheritance(strategy = InheritanceStrategy.NEW_TABLE)
 @DomainObjectLayout(cssClassFa = "envelope")
 public class EmailSend implements Comparable {

        @PrimaryKey(column = "email_id")
        @Persistent(primaryKey = "true", valueStrategy = IdGeneratorStrategy.IDENTITY, column = "email_id")
        @Property(editing=Editing.DISABLED)
        private int id;

        @Property(editing=Editing.DISABLED)
        @PropertyLayout(multiLine = 5)
        @Column(name = "text", length = 65535)
        @Title(sequence = "1")
        private String text;

        ...

        @MemberOrder(sequence = "1")
        public int getId() {
           return id;
        }

        @MemberOrder(sequence = "2")
        public String getText() {
           return text;
        }

        ...
 }

There order of the columns are random, so no @MemberOrder works. Where is the mistake in my code?

riedelinho
  • 404
  • 1
  • 5
  • 15

1 Answers1

2

A couple of things I noted.

  1. @Property only applies to getters, not to fields. We do support this annotation being added to fields, but this is for the use case of also using Project Lombok (whereby Lombok will "move" the annotation to the getter. So your text property is probably showing up as editable even though your intent was probably for it to be non-editable.

  2. You really should use layout.xml, they will save you a ton of time and allow much more sophisticated layouts. You can download an initial one using the "downloadLayoutXml" mixin action that the framework provides.

  3. To your question: I'm not actually sure why the @MemberOrder isn't being honoured here - the code fragment looks okay to me. However, what you might want to do - and which is very flexible tool anyway - is to provide an implementation of TableColumnOrderService as a way of fine-tuning the order (or even omitting properties as columns completely, even in a cross-cutting fashion if needs be).

PS: if you think there really is an issue with @MemberOrder and want to use it, please raise an issue along with a test case app on github.

HTH Dan

Dan Haywood
  • 2,215
  • 2
  • 17
  • 23