| 
jforum example source code file (FindContent.jsp)
 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  | 
              </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="
| ... this post is sponsored by my books ... | |
         
           #1 New Release!  | 
      
         
           FP Best Seller  | 
  
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.