FullTextSearch
When the user types in the full text search input area, then widget filters the rows that match the search query (search criteria is configurable and will usually check if at least one column has corresponding value). This feature makes it easier for users to quickly find the information they are looking for within a List widget.
Basic
It only works for the widget List
type. List widget
How does it look?
How to add?
Example
Step 1
Add extention file FullTextSearchExt.java
Step 2
Add specifications for fulltextsearch fields to corresponding JpaRepository.
@Repository
public interface MyEntityRepository extends JpaRepository<MyEntity, Long>, JpaSpecificationExecutor<MyEntity> {
default Specification<MyEntity> getFullTextSearchSpecification(String value) {
return getAddressLikeIgnoreCaseSpecification(value)
.or(getFullNameLikeIgnoreCaseSpecification(value)
.or(getCustomFieldLikeIgnoreCaseSpecification(value)));
}
default Specification<MyEntity> getFullNameLikeIgnoreCaseSpecification(String value) {
return (root, query, cb) -> FullTextSearchExt.likeIgnoreCase(value, cb, root.get(MyEntity_.fullName));
}
default Specification<MyEntity> getAddressLikeIgnoreCaseSpecification(String value) {
return (root, query, cb) -> FullTextSearchExt.likeIgnoreCase(value, cb, root.get(MyEntity_.address));
}
default Specification<MyEntity> getCustomFieldLikeIgnoreCaseSpecification(String value) {
return (root, query, cb) -> FullTextSearchExt.likeIgnoreCase(value, cb, root.get(MyEntity_.customField));
}
}
Step 4
Add getSpecification to corresponding VersionAwareResponseService.
@Override
protected Specification<MyEntity> getSpecification(BusinessComponent bc) {
var fullTextSearchFilterParam = FullTextSearchExt.getFullTextSearchFilterParam(bc);
var specification = super.getSpecification(bc);
return fullTextSearchFilterParam.map(e -> and(repository.getFullTextSearchSpecification(e), specification)).orElse(specification);
}
Step 5
Add fullTextSearch to corresponding .widget.json.
enabled
true/false
placeholder
- description for fullTextSearch
{
"name": "MyExampleList",
"title": "List",
"type": "List",
"bc": "myexample",
"fields": [
{
"title": "Address",
"key": "address",
"type": "input"
},
{
"title": "Full Name",
"key": "fullName",
"type": "input"
},
{
"title": "customField",
"key": "customField",
"type": "input"
}
],
"options": {
"fullTextSearch": {
"enabled": true,
"placeholder": "Find by Name or Address or Custom Field"
}
}
}