简体   繁体   English

JSF:如何显示搜索结果?

[英]JSF : how to display search results?

i want to implement a small search engine , i have index page where user enter search keyword then he redirected to search results page so how to display the search results since they are dynamically generated i am using lucene and i have this page implemented in jsp (i want to redesign it in jsf) : 我想实现一个小型搜索引擎,我有一个索引页面,用户可以在其中输入搜索关键字,然后他将其重定向到搜索结果页面,因此,如何显示搜索结果,因为它们是动态生成的,我正在使用lucene,并且我在jsp中实现了该页面(我想在jsf中重新设计它):

<p style=" color: green"> <%=Srchr.HitsCount() %> Searching result(s) for :  <%= SearchText %>
<p>------------------------------------------------------------------
<% for (int i = 0 ; i<Srchr.HitsCount() ; i++){ %>
     <p> <%= (i+1) %> : <a href=   <%= Srchr.getHits()[i]  %> > <%= Srchr.getHits()[i] %> </a>

where srchr is the searcher class that access lucene db. 其中srchr是访问lucene db的搜索器类。

please help me . 请帮我 。

thanks 谢谢

  1. have your search button on the home page be 在首页上有您的搜索按钮

     <h:commandButton action="#{searchBean.search}" value="Search" /> 
  2. Let the public String search() method fill the search results into a property of the bean (for example, List<SearchResult> ) public String search()方法将搜索结果填充到Bean的属性中(例如List<SearchResult> )。

  3. Return "searchResults" from the method, which is defined as a navigation outcome in faces-config.xml , and forwards to the searchResults.jsp 从方法中返回"searchResults" ,该方法在faces-config.xml定义为导航结果,并转发到searchResults.jsp

  4. Use <h:dataTable value="#{searchBean.results} var="result" to show the results 使用<h:dataTable value="#{searchBean.results} var="result"显示结果

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM