Search in sources :

Example 1 with SearchContext

use of io.jmix.search.searching.SearchContext in project jmix by jmix-framework.

the class SearchFieldImpl method performSearch.

public void performSearch() {
    Screen frameOwner = ComponentsHelper.getWindowNN(this).getFrameOwner();
    String searchText = getValue();
    ScreenContext screenContext = getScreenContext(frameOwner);
    if (StringUtils.isBlank(searchText)) {
        Notifications notifications = screenContext.getNotifications();
        notifications.create(HUMANIZED).withCaption(messages.getMessage("io.jmix.searchui.noSearchText")).show();
    } else {
        String preparedSearchText = searchText.trim();
        SearchContext searchContext = new SearchContext(preparedSearchText).setSize(searchProperties.getSearchResultPageSize()).setEntities(getEntities());
        SearchResult searchResult = entitySearcher.search(searchContext, searchStrategy);
        if (searchCompletedHandler != null) {
            searchCompletedHandler.accept(new SearchCompletedEvent(this, searchResult));
        }
    }
}
Also used : ScreenContext(io.jmix.ui.screen.ScreenContext) UiControllerUtils.getScreenContext(io.jmix.ui.screen.UiControllerUtils.getScreenContext) SearchResultsScreen(io.jmix.searchui.screen.result.SearchResultsScreen) Screen(io.jmix.ui.screen.Screen) SearchContext(io.jmix.search.searching.SearchContext) SearchResult(io.jmix.search.searching.SearchResult) Notifications(io.jmix.ui.Notifications)

Example 2 with SearchContext

use of io.jmix.search.searching.SearchContext in project jmix-docs by Haulmont.

the class UsingApiScreen method onSearchBtnClick.

// end::search-result-processor[]
// tag::click-event[]
// <1>
@Subscribe("searchBtn")
public void onSearchBtnClick(Button.ClickEvent event) {
    SearchContext searchContext = new SearchContext("silver").setSize(10).setEntities(// <2>
    "search_Order");
    // <3>
    SearchResult searchResult = entitySearcher.search(searchContext);
    Collection<Object> instances = // <4>
    searchResultProcessor.loadEntityInstances(searchResult);
// ...
}
Also used : SearchContext(io.jmix.search.searching.SearchContext) SearchResult(io.jmix.search.searching.SearchResult) Subscribe(io.jmix.ui.screen.Subscribe)

Aggregations

SearchContext (io.jmix.search.searching.SearchContext)2 SearchResult (io.jmix.search.searching.SearchResult)2 SearchResultsScreen (io.jmix.searchui.screen.result.SearchResultsScreen)1 Notifications (io.jmix.ui.Notifications)1 Screen (io.jmix.ui.screen.Screen)1 ScreenContext (io.jmix.ui.screen.ScreenContext)1 Subscribe (io.jmix.ui.screen.Subscribe)1 UiControllerUtils.getScreenContext (io.jmix.ui.screen.UiControllerUtils.getScreenContext)1