Miscellaneous Questions (IDs, Disabling fields & Fields layout)

Dear All,

I kindly need your feedback on the following 3 questions:

  1. I need to have a unique auto-genarated ID per entity. So I am extending BaseIntegerIdEntity for this purpose.
    However, the generated Ids are incremental per user session only. For example, if the same user creates 2 records in the same session, he will get id 1 and then id 2. Next time he logs in, he might get id 101, id 102, although IDs between 2 and 101 are not taken. How can I override this behavior? Moreover, the ID is showing with , seperators. For example, 1201 is showing as 1,201. How can I remove the separator?

  2. I need to disable some fields (that are part of the entity uniqueness) when updating and not when adding. So basically disallowing the user from updating those attributes, but he can set them upon creation. What is the best way to implement this?

  3. When building a screen where some fields span more than one row, the layout of the screen gets corrupted.
    For example, in the attached image of the items screen, when I increment the rows of the field “Long Description” to 2, some kind of separator shows between the fields “Mrc Price” and “Otc Discount” so that the later field stays aligned with the field “Type”. How to remove this separator and having the fields show just one after the other with equal separation regardless of the number of rows for each?

Many Thanks in advance.

Shady

ItemsScreen

Thank You

Hi Konstantin,

This is not a table column. It is a disabled text field on the browser screen.
Could you please share a code example on how to do this?

Much appreciated.

Hi Shady,

  1. First of all, I would not recommend using ID as a semantically meaningful field. It should be hidden from user and its type and values should be chosen only from the performance point of view. In order to have an incremental integer field, add a separate attribute and fill it using the Sequence Generation mechanism.

  2. Set editable = false for these fields and enable them programmatically in the postInit() method of the screen controller:


protected void postInit() {
    if (!PersistenceHelper.isNew(getItem())) {
      someField.setEditable(true);
    }
}
  1. It works as designed. To avoid aligning fields in columns use two different FieldGroups.

Hi Konstantic,

  1. Thanks for the feedback. I know that usually those IDs are meaningless to show to the user, however, in this case, they are part of the requirements, so I have to show them on the screens.
    What about the second part of the question (removing the comma delimiters)? How to do that?

  2. Thanks, it is working perfectly.

  3. I tried using 2 fieldGroups, however, they will display below each other and not next to each other. The whole purpose is to split the fields over 2 columns without any separators. Please let me know how to achieve this.

Thanks in advance.

To display 2 fieldgroups to next each other, place a HBOX container in that part of screen, and put those 2 fieldgroups into this HBOX, then they will be placed horizontally.

About displaying IDs: add a formatter to the table column.

Add a text field to the screen and do not connect it to any datasources. In postInit() method, set the field value:


idField.setValue(getItem().getId().toString());