Trace: • Standard Sorting on the Server Side
User-friendly UIs prepare and display data in clearly arranged form. This includes clear and relevant sorting of data.
There are several different ways to sort data, and sorting can happen at various tiers. The client (client tier) can handle sorting, although that would mean that unwanted logic is located at the client. The database (data tier) also offers ways to sort data, for example, through the use of views. Unfortunately, not all databases support sorting using views. That only leaves the application server and, therefore, the business logic (enterprise tier) for sorting.
The following instruction sorts the data. Please note that this is standard sorting. If the client requests a different sorting method, it will be preferred.
public DBStorage getUserDefaults() throws Exception { DBStorage userDefaults = (DBStorage)get("userDefaults"); if (userDefaults == null) { userDefaults = new DBStorage(); userDefaults.setDBAccess(getDBAccess()); userDefaults.setWritebackTable("USERS"); userDefaults.setDefaultSort(new SortDefinition(false, "USERNAME")); userDefaults.open(); put("userDefaults", userDefaults); } return userDefaults; }