KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > portlets > communication > forum > component > UIForumSearcher


1 /***************************************************************************
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved. *
3  * Please look at license.txt in info directory for more license detail. *
4  **************************************************************************/

5 package org.exoplatform.portlets.communication.forum.component;
6
7 import java.util.ArrayList JavaDoc;
8 import java.util.List JavaDoc;
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 /**
18  * @author Tuan Nguyen (tuan08@users.sourceforge.net)
19  * @since Aug 27, 2004
20  * @version $Id: UIContentSearcher.java,v 1.1 2004/10/25 03:48:11 tuan08 Exp $
21  */

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 JavaDoc {
28     setId("UISearcher") ;
29     plugin_ = (ForumIndexerPlugin)service.getIndexerPlugin(ForumIndexerPlugin.IDENTIFIER) ;
30     fservice_ = fservice ;
31     init(service) ;
32   }
33   
34   public Searcher getSearcher() throws Exception JavaDoc {
35     Searcher searcher = plugin_.getSearcher();
36     return searcher ;
37   }
38   
39   protected UIComponent customizeUISearchBar(IndexingService service ) throws Exception JavaDoc {
40     UISearchBar uiBar = new UISearchBar();
41     List JavaDoc options = new ArrayList JavaDoc() ;
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 JavaDoc {
51     this.setRenderedComponent(UIAdvancedSearch.class) ;
52   }
53   
54   protected UIComponent customizeUIAdvancedSearch(IndexingService service) throws Exception JavaDoc {
55     return new UIAdvancedSearch(fservice_) ;
56   }
57 }
Popular Tags