1 5 package org.exoplatform.portlets.communication.forum.component; 6 7 import java.util.ArrayList ; 8 import java.util.List ; 9 import javax.faces.component.UIComponent; 10 import org.exoplatform.faces.core.component.model.SelectItem; 11 import org.exoplatform.faces.search.component.UISearchBar; 12 import org.exoplatform.faces.search.component.UISearcher; 13 import org.exoplatform.services.communication.forum.ForumIndexerPlugin; 14 import org.exoplatform.services.communication.forum.ForumService; 15 import org.exoplatform.services.indexing.IndexingService; 16 import org.exoplatform.services.indexing.Searcher; 17 22 public class UIForumSearcher extends UISearcher { 23 private ForumIndexerPlugin plugin_ ; 24 private ForumService fservice_ ; 25 26 public UIForumSearcher(ForumService fservice , 27 IndexingService service) throws Exception { 28 setId("UISearcher") ; 29 plugin_ = (ForumIndexerPlugin)service.getIndexerPlugin(ForumIndexerPlugin.IDENTIFIER) ; 30 fservice_ = fservice ; 31 init(service) ; 32 } 33 34 public Searcher getSearcher() throws Exception { 35 Searcher searcher = plugin_.getSearcher(); 36 return searcher ; 37 } 38 39 protected UIComponent customizeUISearchBar(IndexingService service ) throws Exception { 40 UISearchBar uiBar = new UISearchBar(); 41 List options = new ArrayList () ; 42 options.add(new SelectItem("Search All", "")); 43 options.add(new SelectItem("By Subject", ForumIndexerPlugin.SUBJECT_FIELD)); 44 options.add(new SelectItem("By Post", ForumIndexerPlugin.BODY_FIELD)); 45 options.add(new SelectItem("By Author", ForumIndexerPlugin.AUTHOR_FIELD)); 46 uiBar.setSearchOptions(options) ; 47 return uiBar ; 48 } 49 50 public void showAdvancedSearch() throws Exception { 51 this.setRenderedComponent(UIAdvancedSearch.class) ; 52 } 53 54 protected UIComponent customizeUIAdvancedSearch(IndexingService service) throws Exception { 55 return new UIAdvancedSearch(fservice_) ; 56 } 57 } | Popular Tags |