April 2018
Intermediate to advanced
202 pages
4h 48m
English
Filtering can be implemented by adding UI components such as a TextField and a ComoboBox with value listeners on them. When the user changes the filtering components, the value listeners update the data by passing their values to the backend and updating the view accordingly. For example, in order to filter by last name, the UserRepository.findAll method should accept a string with the value to match:
public class UserRepository { public static List<User> findAll(String lastName) { return JPAService.runInTransaction(em -> em.createQuery("select u from User u where u.lastName like :lastName") .setParameter("lastName", lastName) .getResultList() ); } ...}
Read now
Unlock full access