/** * $RCSfile: search.jsp,v $ * $Revision: 1.5 $ * $Date: 2002/09/30 20:22:27 $ */ %> com.jivesoftware.util.*, com.jivesoftware.forum.*, com.jivesoftware.forum.util.*, com.jivesoftware.base.*" errorPage="error.jsp" %> // // This page handles logging into the system as well as logouts. %> // The forum ID (optional) long forumID = ParamUtils.getLongParameter(request,"forum",-1L); // The query String queryText = ParamUtils.getParameter(request,"q"); // The starting index of results to show: int start = ParamUtils.getIntParameter(request,"start",0); // The number of results to show per page: int range = 15; // Optionally load a forum: Forum forum = null; try { forum = forumFactory.getForum(forumID); } catch (ForumNotFoundException ignored) {} %> Use the form below to search the forum content. Search For: // If a query was submitted, try running a search. First, create a // Query object and populate it (we fully qualify the Query object name // because some appservers have classes already named "Query"): com.jivesoftware.forum.Query query = null; // Next, determine if this is a global or local search. A global search // searches over all categories and forums and a local one will just search // a single forum. If the forum object is not null that means we should // search on a forum, otherwise we'll search globally. We specify these types // of searches based on how we create a query object: if (forum != null) { // local search: query = forum.createQuery(); } else { query = forumFactory.createQuery(); } // Now, set the query text: query.setQueryString(queryText); // Execute the query - this returns an Iterator of ForumMessages. Limit the // number of results we get to 'range' results and specify the starting // index of results (this allows us to paginate through the results): Iterator results = query.getResults(start, range); // If there were no results, print out a message: if (!results.hasNext()) { %> No results for "" - please try different search terms. } else { // First, print a summary of the results: %> Results: , showing page page: int counter = start; while (results.hasNext()) { ForumMessage message = (ForumMessage)results.next(); counter ++; ForumThread searchThread = message.getForumThread(); Forum searchForum = searchThread.getForum(); %> ) > } // end of results while loop } // end of else } // end of if %> document.searchform.q.focus(); //-->