Some time ago I made customized advanced search results view – no two boxes like in standard Alfresco, but three boxes – the third one for viewing special content type. Now I wanted to add this results screen as a default result of searching via the simple search box.
When I firstly saw r:simpleSearch component and no documentation, I wasn't happy. But after while I realized that it's very simple, thanks to actionListener parameter on that component:
<r:simpleSearch id="search" actionListener="#{BrowseSessionBean.search}" />
This component creates that very known search box
That action listener, search, is defined in BrowseBean, but I did my own (I copied and edited it :-)). All what this listener does is just setting Search Context and then redirects to results page – returns adequate outcome string to faces navigator.
public void search(ActionEvent event){
UISimpleSearch search = (UISimpleSearch)event.getComponent();
this.navigator.setSearchContext(search.getSearchContext());
FacesContext context = FacesContext.getCurrentInstance();
context.getApplication().getNavigationHandler().handleNavigation(context, null, "browseSearchResults");
}
Navigation rule in faces config navigates in this case from everywhere to my own search results page thanks to this rule:
<navigation-rule>
<from-view-id>/jsp/*</from-view-id>
<navigation-case>
<from-outcome>browseSearchResults</from-outcome>
<to-view-id>/jsp/archivace/view-search-results.jsp</to-view-id>
</navigation-case>
</navigation-rule>
That's all, view-search-results is up to you 🙂