1 5 package org.exoplatform.faces.search.component; 6 7 import java.util.List ; 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 21 public class UISearchSummary extends UIExoCommand { 22 final static public String COMPONENT_FAMILY = "org.exoplatform.faces.search.component.UISearchSummary" ; 23 24 public final int PAGE_SIZE = 15 ; 25 public final static String VIEW_ACTION = "view" ; 26 public final static String 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 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 { 46 uiPageIterator_.setPageList(result) ; 47 } 48 49 public String getFamily() { return COMPONENT_FAMILY ; } 50 51 static public class ViewActionListener extends ExoActionListener { 52 public void execute(ExoActionEvent event) throws Exception { 53 UISearchSummary uiSummary = (UISearchSummary) event.getSource(); 54 String 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 |