Skip to content

Filters

Miguel Pérez Colom edited this page Oct 6, 2024 · 3 revisions

In Mateu for creating a crud you implement the Crud interface. The Crudinterface is defined as follows:

public interface Crud<SearchForm, Row> extends Listing<SearchForm, Row> {
    
}

The first parameter in the Crud interface is the class defining the filter fields, which will be used when fetching rows.

The first field in that form will always be shown in the crud as the search field while, if there are more field in the form, a button Filters will be visible so the user can access and set all the form filters as in the images below:

Please notice that any class can be used for the search form, even the crud itself as here:

public class ProgrammingLanguages
    implements Crud<ProgrammingLanguages, LanguageRow>, HasTitle, HasSubtitle {

  @Placeholder("here the language name")
  String name;

  LanguageRow.LanguageTarget target;

  boolean jvm;

  DatesRange born;

  @Override
  public Mono<Page<LanguageRow>> fetchRows(
          String searchText, ProgrammingLanguages filters, Pageable pageable) {
    // query
  }

}

As you see, in the end, the filters object is passed as a parameter to the methods for fetching the rows:

  @Override
  public Mono<Page<LanguageRow>> fetchRows(
          String searchText, ProgrammingLanguages filters, Pageable pageable) {
    // query
  }
Clone this wiki locally