KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > faces > search > component > UISearchSummary


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.faces.search.component;
6
7 import java.util.List JavaDoc;
8 import org.apache.lucene.document.Document;
9 import org.exoplatform.commons.utils.PageList;
10 import org.exoplatform.faces.core.component.UIExoCommand;
11 import org.exoplatform.faces.core.component.UIPageListIterator;
12 import org.exoplatform.faces.core.component.model.Parameter;
13 import org.exoplatform.faces.core.event.ExoActionEvent;
14 import org.exoplatform.faces.core.event.ExoActionListener;
15 import org.exoplatform.faces.search.component.model.DocumentDataHandler;
16 /**
17  * @author Tuan Nguyen (tuan08@users.sourceforge.net)
18  * @since Aug 27, 2004
19  * @version $Id: UISearchSummary.java,v 1.1 2004/10/25 03:34:07 tuan08 Exp $
20  */

21 public class UISearchSummary extends UIExoCommand {
22   final static public String JavaDoc COMPONENT_FAMILY = "org.exoplatform.faces.search.component.UISearchSummary" ;
23   
24   public final int PAGE_SIZE = 15 ;
25   public final static String JavaDoc VIEW_ACTION = "view" ;
26   public final static String JavaDoc DOCUMENT_INDEX = "index" ;
27   public static Parameter viewParam_ = new Parameter(ACTION, VIEW_ACTION) ;
28   
29   private UIPageListIterator uiPageIterator_ ;
30   private DocumentDataHandler dataHandler_ ;
31   
32   public UISearchSummary(DocumentDataHandler dataHandler) {
33     setId("UISearchSummary") ;
34     setClazz("UISearchResult");
35     setRendererType("SearchSummaryRenderer") ;
36     dataHandler_ = dataHandler ;
37     uiPageIterator_ = new UIPageListIterator(dataHandler) ;
38     List JavaDoc children = getChildren() ;
39     children.add(uiPageIterator_);
40     addActionListener(ViewActionListener.class, VIEW_ACTION) ;
41   }
42   
43   public UIPageListIterator getUIPageIterator() { return uiPageIterator_ ; }
44   
45   public void setSearchResult(PageList result) throws Exception JavaDoc {
46     uiPageIterator_.setPageList(result) ;
47   }
48   
49   public String JavaDoc getFamily() { return COMPONENT_FAMILY ; }
50   
51   static public class ViewActionListener extends ExoActionListener {
52     public void execute(ExoActionEvent event) throws Exception JavaDoc {
53       UISearchSummary uiSummary = (UISearchSummary) event.getSource();
54       String JavaDoc indexStr = event.getParameter(DOCUMENT_INDEX) ;
55       int idx = Integer.parseInt(indexStr) ;
56       Document doc = (Document)uiSummary.dataHandler_.getObjectInPage(idx) ;
57       UISearcher uiSearcher = (UISearcher) uiSummary.getParent();
58       uiSearcher.viewDocument(doc) ;
59     }
60   }
61 }
Popular Tags