TableColumnOrderServiceUsingTxtFile

Provides a simple mechanism to order the columns of both parented and standalone collections by reading a flat file containing the list of the associations (usually properties, but collections are also supported), in the desired order, one associationId per line.

The files are located relative to the class itself. A number of conventions are supported:

  • for parented collections:

    (where '_' is a wildcard for any collection of the element type

    • ParentClassName#collectionId.columnOrder.txt

    • ParentClassName#collectionId.columnOrder.fallback.txt

    • ParentClassName#_.ElementTypeClassName.columnOrder.txt

    • ParentClassName#_.ElementTypeClassName.columnOrder.fallback.txt

    • ElementTypeClassName.columnOrder.txt

    • ElementTypeClassName.columnOrder.fallback.txt

  • for standalone collections:

    • DomainTypeClassName.columnOrder.txt

    • DomainTypeClassName.columnOrder.fallback.txt

Any associations omitted from the file will not be shown as columns of the table. The associationId must also be an exact match, so can be ignored by commenting out, eg with "#".

Also note that association that have been explicitly hidden from tables using PropertyLayout#hidden() @PropertyLayout#hidden or CollectionLayout#hidden() are never shown, irrespective of whether they are listed in the files. You may therefore prefer to not hide properties with annotations, and then rely solely on these external columnOrder.txt files. This has the further benefit that files can be modified at runtime and will be automatically picked up without requiring a restart of the application.

API

TableColumnOrderServiceUsingTxtFile.java
class TableColumnOrderServiceUsingTxtFile {
  List<String> orderParented(Object domainObject, String collectionId, Class<?> elementType, List<String> associationIds)     (1)
  List<String> orderStandalone(Class<?> domainType, List<String> associationIds)     (2)
}
1 orderParented(Object, String, Class, List)

Reads association Ids of the parented collection from a file.

2 orderStandalone(Class, List)

Reads associationIds of a standalone collection from a file.

Members

orderParented(Object, String, Class, List)

Reads association Ids of the parented collection from a file.

The search algorithm is:

  • ParentClassName#collectionId.columnOrder.txt

  • ParentClassName#collectionId.columnOrder.fallback.txt

  • ParentClassName#_.ElementTypeClassName.columnOrder.txt

    (where '_' is a wildcard for any collection of the element type

  • ParentClassName#_.ElementTypeClassName.columnOrder.fallback.txt

  • ElementTypeClassName.columnOrder.txt

  • ElementTypeClassName.columnOrder.fallback.txt

Additional files can be provided by overriding #addResourceNames(Class, String, Class, List)

orderStandalone(Class, List)

Reads associationIds of a standalone collection from a file.

The search algorithm is:

  • DomainTypeClassName.columnOrder.txt

  • DomainTypeClassName.columnOrder.fallback.txt

Additional files can be provided by overriding #addResourceNames(Class, List) .