Skip to content

Filters

miguelperezcolom edited this page Sep 22, 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 Flux<LanguageRow> fetchRows(
      ProgrammingLanguages filters, List<SortCriteria> sortOrders, int offset, int limit) {
  }

  @Override
  public Mono<Long> fetchCount(ProgrammingLanguages filters) {
  }

}

In the end, the filters object is passed as a parameter to the methods for fetching the rows:

  @Override
  public Flux<LanguageRow> fetchRows(
      ProgrammingLanguages filters, // here the filters 
      List<SortCriteria> sortOrders, 
      int offset, 
      int limit
  ) {
  }
Clone this wiki locally