This document discusses two examples of using Google Web Toolkit (GWT) to build user interfaces for large amounts of data: 1) a table of employees that allows searching, sorting, and paging of employee data; and 2) a suggest box for autocompleting employee names from a remote data source. It provides details on the client-side and server-side components needed to implement filtering, sorting, paging and querying of large data sets to display relevant results efficiently.
9. Client side
Needs to know
• Table Definition: captions,
searchable/filterable rows
• Table Data
9
10. Client Table Definition
new ClientTableDefinition(
new TextColumnDefinition("firstName", SORTABLE,
!FILTERABLE, SEARCHABLE, !HIDDEN),
new TextColumnDefinition("gender", SORTABLE,
FILTERABLE, !SEARCHABLE, !HIDDEN),
…
);
10
11. TableResult
class InitialResult {
TableDefinition def;
List<String> captions;
List<String> searchValues;
List<List<String>> availableFilters;
}
class TableResult {
InitialResult initialResult;
List<TableRow> tableRows;
String sortColumn; SortOrder sortOrder;
int pageSize; int startIndex; int totalCount;
}
11
12. Server side
Needs to know
• Table Definition: captions, filterable
rows, technical field names
• Mapping of search/filter/order to
query
• Mapping of database results to table
rows
12
13. Server side sequence
• loadSaveSettings
• if (firstRequest)
captions, search/filter values
• createQuery: search, filter, order
• executeQuery: with paging
• mapQueryResults
• executeCountQuery: no „order“
• setPagerData
13
Request
Response
14. Server Table Definition
new TableDefinition<Employee>(
new EmployeeQueryCreator(),
new TextColumn("firstName",
e -> e.getFirstName()),
new FilterColumn("gender",
e -> e.getGender(), GENDER.values()),
…
);
14
15. Usability: LIKE
Query:
SELECT e FROM Employee e where e.firstName LIKE
:searchValue
Case-insensitive collation:
@Column(columnDefinition=
"VARCHAR(255) COLLATE "English UCC"")
private String firstName;
15
16. Usability: search = rendering
Rendered string for supervisor:
firstName + " " + lastName
Search string: „and“
where firstName like 'and%'
or lastName like 'and%'
Search string: „andreas hu“
where firstName like 'andreas%'
and lastName like 'hu%'
16
17. How do we select an employee
in a small widget by name?
17