alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  
</tr> </wiki:SearchResultIterator> <wiki:IfNoSearchResults> <tr> <td colspan="2">No results </tr> </wiki:IfNoSearchResults> </table> </div> </div> <p> <% if( startVal > 0 ) { %> <wiki:Link jsp="Search.jsp"> <wiki:Param name="query" value="<%=URLEncoder.encode(query)%>"/> <wiki:Param name="start" value="<%=Integer.toString(startVal-prevSize)%>"/> Get previous <%=prevSize%> results </wiki:Link>. <% } %> <% if( endVal < list.size() ) { %> <wiki:Link jsp="Search.jsp"> <wiki:Param name="query" value="<%=URLEncoder.encode(query)%>"/> <wiki:Param name="start" value="<%=Integer.toString(endVal)%>"/> Get next <%=nextSize%> results </wiki:Link>. <% } %> </p> <p> <a href="http://www.google.com/search?q=<%=query%>" target="_blank">Try this same search on Google! </p> <hr /> </wiki:SearchResults> <form action=" <p> Enter your query here:<br /> <input type="text" name="query" size="40" value="<%=query%>" />

<p> <input type="submit" name="ok" value="Find!" /> <input type="submit" name="go" value="Go!" />

</form> <wiki:InsertPage page="SearchPageHelp"/>

Other jforum examples (source code examples)

Here is a short list of links related to this jforum FindContent.jsp source code file:

jforum example source code file (FindContent.jsp)

This example jforum source code file (FindContent.jsp) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - jforum tags/keywords

collection, enter, find, fixme, get, get, go, google, google, page, score, string, string, try

The jforum FindContent.jsp source code

<%@ taglib uri="/WEB-INF/jspwiki.tld" prefix="wiki" %>
<%@ page import="com.ecyrd.jspwiki.*" %>
<%@ page import="java.util.Collection" %>
<%@ page import="java.net.URLEncoder" %>

<%-- FIXME: Get rid of the scriptlets. --%>
<%
    String query = (String)pageContext.getAttribute( "query",
                                                     PageContext.REQUEST_SCOPE );
    if( query == null ) query = "";
    
    String start = (String)request.getParameter("start");
    
    int startVal = 0;
    
    try
    {
        startVal = Integer.parseInt(start);
    } catch(Exception e) {}
    
    if( startVal < 0 ) startVal = 0;
    
    int endVal = startVal + 20;
    
    Collection list = (Collection)pageContext.getAttribute( "searchresults",
                                                             PageContext.REQUEST_SCOPE );
                                                             
    int prevSize = 0, nextSize = 0;
    
    if( list != null )
    {
      if( endVal > list.size() ) endVal = list.size();
      prevSize = Math.max( startVal, 20 );
      nextSize = Math.min(list.size() - endVal, 20);
    }
%>

      <h2>Find pages

      <wiki:SearchResults>
          <h4>Search results for '<%=query%>'

          <p>
          <i>Found  hits, here are the results from <%=startVal+1%> to <%=endVal%>.
          </p>

          <div class="zebra-table">
          <div class="graphBars">
          <table border="0" cellpadding="4" width="80%">

          <tr>
             <th align="left">Page
             <th align="left">Score
          </tr>

          <wiki:SearchResultIterator id="searchref" start="<%=Integer.toString(startVal)%>" maxItems="20">
              <tr>
                  <td>
<%
    String[] contexts = searchref.getContexts();
    if ((contexts != null) && (contexts.length > 0)) {
      out.println("<br />");
      out.println("<div class=\"fragment\">");
      for (int i = 0; i < contexts.length; i++) {
        if (i > 0)
          out.println("<span class=\"fragment_ellipsis\"> ... ");
        out.println(contexts[i]);
      }
      out.println("</div>");
    }
%>

</td>
                  <td class="gBar"><%=searchref.getScore()%>
... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.