You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jspwiki.apache.org by Harry Metske <ha...@gmail.com> on 2009/06/08 20:44:10 UTC

Re: svn commit: r782495 - in /incubator/jspwiki/trunk/src: WebContent/ WebContent/scripts/ WebContent/templates/default/ java/org/apache/wiki/ java/org/apache/wiki/action/ java/org/apache/wiki/tags/

Andrew,

should this patch have fixed
https://issues.apache.org/jira/browse/JSPWIKI-510 (only for 3.0 of course) ?

Harry

2009/6/8 <aj...@apache.org>

> Author: ajaquith
> Date: Mon Jun  8 01:37:33 2009
> New Revision: 782495
>
> URL: http://svn.apache.org/viewvc?rev=782495&view=rev
> Log:
> Search.jsp migrated to Stripes. SearchActionBean now provides searching
> logic, including an ajaxSearch() method that filters results correctly (this
> is not hooked up to the client JavaScript yet, but it should be
> straightforward to do). Still some i18n cleanup to do.
>
> Modified:
>    incubator/jspwiki/trunk/src/WebContent/Search.jsp
>    incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-common.js
>    incubator/jspwiki/trunk/src/WebContent/templates/default/FindContent.jsp
>    incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiContext.java
>
>  incubator/jspwiki/trunk/src/java/org/apache/wiki/action/SearchActionBean.java
>
>  incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IfNoSearchResultsTag.java
>
>  incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultIteratorTag.java
>
>  incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsSizeTag.java
>
>  incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsTag.java
>
> Modified: incubator/jspwiki/trunk/src/WebContent/Search.jsp
> URL:
> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/WebContent/Search.jsp?rev=782495&r1=782494&r2=782495&view=diff
>
> ==============================================================================
> --- incubator/jspwiki/trunk/src/WebContent/Search.jsp (original)
> +++ incubator/jspwiki/trunk/src/WebContent/Search.jsp Mon Jun  8 01:37:33
> 2009
> @@ -18,108 +18,12 @@
>     specific language governing permissions and limitations
>     under the License.
>  --%>
> -<%@ page import="org.apache.wiki.log.Logger" %>
> -<%@ page import="org.apache.wiki.log.LoggerFactory" %>
> -<%@ page import="org.apache.wiki.*" %>
> -<%@ page import="org.apache.wiki.auth.*" %>
> -<%@ page import="org.apache.wiki.auth.permissions.*" %>
> -<%@ page import="java.util.*" %>
> +<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld" prefix="s" %>
>  <%@ page errorPage="/Error.jsp" %>
> -<%@ page import="org.apache.wiki.search.*" %>
> -<%@ taglib uri="http://jakarta.apache.org/jspwiki.tld" prefix="wiki" %>
> -<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld"
> prefix="stripes" %>
> -<%@ page import="org.apache.wiki.util.TextUtil" %>
> -<%@ page import="org.apache.wiki.api.WikiPage" %>
> -<stripes:useActionBean beanclass="org.apache.wiki.action.SearchActionBean"
> event="find" id="wikiActionBean" />
> +<s:useActionBean beanclass="org.apache.wiki.action.SearchActionBean"
> event="search" executeResolution="true" id="wikiActionBean" />
> +<s:layout-render name="${templates['DefaultLayout.jsp']}">
> +  <s:layout-component name="content">
> +      <jsp:include page="${templates['FindContent.jsp']}" />
> +  </s:layout-component>
> +</s:layout-render>
>
> -<%!
> -    Logger log = LoggerFactory.getLogger("JSPWikiSearch");
> -%>
> -
> -<%
> -    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
> -    // Create wiki context and check for authorization
> -    WikiContext wikiContext = wiki.createContext( request,
> WikiContext.FIND );
> -    String pagereq = wikiContext.getPage().getName();
> -
> -    // Get the search results
> -    Collection list = null;
> -    String query = request.getParameter( "query");
> -    String go    = request.getParameter("go");
> -
> -    if( query != null )
> -    {
> -        log.info("Searching for string "+query);
> -
> -        try
> -        {
> -            list = wiki.findPages( query );
> -
> -            //
> -            //  Filter down to only those that we actually have a
> permission to view
> -            //
> -            AuthorizationManager mgr = wiki.getAuthorizationManager();
> -
> -            ArrayList filteredList = new ArrayList();
> -
> -            for( Iterator i = list.iterator(); i.hasNext(); )
> -            {
> -                SearchResult r = (SearchResult)i.next();
> -
> -                WikiPage p = r.getPage();
> -
> -                PagePermission pp = new PagePermission( p,
> PagePermission.VIEW_ACTION );
> -
> -                try
> -                {
> -                    if( mgr.checkPermission( wikiContext.getWikiSession(),
> pp ) )
> -                    {
> -                        filteredList.add( r );
> -                    }
> -                }
> -                catch( Exception e ) { log.error( "Searching for page "+p,
> e ); }
> -            }
> -
> -            pageContext.setAttribute( "searchresults",
> -                                      filteredList,
> -                                      PageContext.REQUEST_SCOPE );
> -        }
> -        catch( Exception e )
> -        {
> -            wikiContext.getWikiSession().addMessage( e.getMessage() );
> -        }
> -
> -        query = TextUtil.replaceEntities( query );
> -
> -        pageContext.setAttribute( "query",
> -                                  query,
> -                                  PageContext.REQUEST_SCOPE );
> -
> -        //
> -        //  Did the user click on "go"?
> -        //
> -        if( go != null )
> -        {
> -            if( list != null && list.size() > 0 )
> -            {
> -                SearchResult sr = (SearchResult) list.iterator().next();
> -
> -                WikiPage wikiPage = sr.getPage();
> -
> -                String url = wikiContext.getViewURL( wikiPage.getName() );
> -
> -                response.sendRedirect( url );
> -
> -                return;
> -            }
> -        }
> -    }
> -
> -    // Set the content type and include the response content
> -    response.setContentType("text/html;
> charset="+wiki.getContentEncoding() );
> -    String contentPage = wiki.getTemplateManager().findJSP( pageContext,
> -
>  wikiContext.getTemplate(),
> -
>  "ViewTemplate.jsp" );
> -%><wiki:Include page="<%=contentPage%>" /><%
> -    log.debug("SEARCH COMPLETE");
> -%>
>
> Modified: incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-common.js
> URL:
> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-common.js?rev=782495&r1=782494&r2=782495&view=diff
>
> ==============================================================================
> --- incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-common.js
> (original)
> +++ incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-common.js Mon
> Jun  8 01:37:33 2009
> @@ -931,9 +931,9 @@
>                        if (option.value == match) option.selected = true;
>                });
>
> -               new Ajax(Wiki.TemplateUrl+'AJAXSearch.jsp', {
> -                       postBody: $('searchform2').toQueryString(),
> -                       update: 'searchResult2',
> +               new Ajax(Wiki.BasePath+'Search.action', {
> +                       postBody:
> "ajaxSearch=&"+$('searchform2').toQueryString(),
> +                       update: 'searchResult2',
>                        method: 'post',
>                        onComplete: function() {
>                                $('spin').hide();
>
> Modified:
> incubator/jspwiki/trunk/src/WebContent/templates/default/FindContent.jsp
> URL:
> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/WebContent/templates/default/FindContent.jsp?rev=782495&r1=782494&r2=782495&view=diff
>
> ==============================================================================
> ---
> incubator/jspwiki/trunk/src/WebContent/templates/default/FindContent.jsp
> (original)
> +++
> incubator/jspwiki/trunk/src/WebContent/templates/default/FindContent.jsp Mon
> Jun  8 01:37:33 2009
> @@ -27,24 +27,18 @@
>  <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
>  <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
>  <%@ page import="javax.servlet.jsp.jstl.fmt.*" %>
> -<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld"
> prefix="stripes" %>
> +<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld" prefix="s" %>
>
>  <wiki:TabbedSection>
>  <wiki:Tab id="findcontent" titleKey="find.tab" accesskey="s">
>
> -<form action="<wiki:Link format='url' jsp='Search.jsp'/>"
> -       class="wikiform"
> -          id="searchform2"
> -         accept-charset="<wiki:ContentEncoding/>">
> -
> +<s:form beanclass="org.apache.wiki.action.SearchActionBean"
> class="wikiform"
> +    id="searchform2" acceptcharset="UTF-8">
> +
>   <h4><fmt:message key="find.input" /></h4>
>   <p>
> -    <input type="text"
> -           name="query" id="query2"
> -          value="<c:out value='${query}'/>"
> -           size="32" />
> -
> -    <input type="checkbox" name="details" id="details" <c:if
> test='${param.details == "on"}'>checked='checked'</c:if> />
> +    <s:text name="query" id="query2" size="32" />
> +    <s:checkbox name="details" id="details" />
>     <fmt:message key="find.details" />
>
>     <select name="scope" id="scope">
> @@ -55,16 +49,83 @@
>       <option value="attachment:" <c:if test='${param.scope eq
> "attachment:"}'>selected="selected"</c:if> ><fmt:message
> key='find.scope.attach' /></option>
>     </select>
>
> -       <input type="submit" name="ok" id="ok" value="<fmt:message
> key="find.submit.find" />" />
> -       <input type="submit" name="go" id="go" value="<fmt:message
> key="find.submit.go" />" />
> -    <input type="hidden" name="start" id="start" value="0" />
> -    <input type="hidden" name="maxitems" id="maxitems" value="20" />
> +    <s:submit name="search" id="ok" value="<fmt:message
> key='find.submit.find' />" />
> +    <s:submit name="go" id="go" value="<fmt:message key='find.submit.go'
> />" />
> +    <s:hidden name="start" id="start" value="0" />
> +    <s:hidden name="maxItems" id="maxitems" value="20" />
>
>     <span id="spin" class="spin"
> style="position:absolute;display:none;"></span>
>   </p>
> -</form>
> +</s:form>
> +
> +<div id="searchResult2">
> +  <wiki:SearchResults>
> +
> +    <h4><fmt:message key="find.heading.results"><fmt:param><c:out
> value="${wikiActionBean.query}" /></fmt:param></fmt:message></h4>
> +    <p>
> +      <fmt:message key="find.externalsearch" />
> +      <a class="external" href="http://www.google.com/search?q=<c:out
> value='${wikiActionBean.query}' />" title="Google Search '<c:out
> value='${wikiActionBean.query}' />'" target="_blank">Google</a><img
> class="outlink" src="images/out.png" alt="" />
> +      |
> +      <a class="external" href="
> http://en.wikipedia.org/wiki/Special:Search?search=<c:out
> value='${wikiActionBean.query}' />" title="Wikipedia Search '<c:out
> value='${wikiActionBean.query}' />'" target="_blank">Wikipedia</a><img
> class="outlink" src="images/out.png" alt="" />
> +    </p>
> +
> +    <wiki:SetPagination start="${wikiActionBean.start}"
> total="${wikiActionBean.resultsCount}" pagesize="20" maxlinks="9"
> fmtkey="info.pagination" onclick="$('start').value=%s;
> SearchBox.runfullsearch();" />
> +
> +    <div class="graphBars">
> +      <div class="zebra-table">
> +        <table class="wikitable">
> +
> +          <tr>
> +             <th align="left"><fmt:message key="find.results.page" /></th>
> +             <th align="left"><fmt:message key="find.results.score"
> /></th>
> +          </tr>
> +
> +          <wiki:SearchResultIterator id="searchref"
> start="${wikiActionBean.start}" maxItems="${wikiActionBean.maxItems}">
> +          <tr>
> +            <td><wiki:LinkTo><wiki:PageName/></wiki:LinkTo></td>
> +            <td><span class="gBar"><%= searchref.getScore() %></span></td>
> +          </tr>
> +
> +          <c:if test="${wikiActionBean.details == 'true'}">
> +  <%
> +            String[] contexts = searchref.getContexts();
> +            if( (contexts != null) && (contexts.length > 0) )
> +            {
> +  %>
> +          <tr class="odd">
> +            <td colspan="2">
> +              <div class="fragment">
> +  <%
> +              for (int i = 0; i < contexts.length; i++)
> +              {
> +  %>
> +                <%= (i > 0 ) ? "<span class='fragment_ellipsis'> ...
> </span>" : ""  %>
> +                <%= contexts[i]  %>
> +  <%
> +              }
> +  %>
> +               </div>
> +             </td>
> +           </tr>
> +  <%
> +            }
> +  %>
> +          </c:if><%-- details --%>
> +        </wiki:SearchResultIterator>
> +
> +        <wiki:IfNoSearchResults>
> +          <tr>
> +            <td class="nosearchresult" colspan="2"><fmt:message
> key="find.noresults" /></td>
> +          </tr>
> +        </wiki:IfNoSearchResults>
> +
> +        </table>
> +      </div>
> +    </div>
> +    ${pagination}
>
> -<div id="searchResult2"><wiki:Include page="AJAXSearch.jsp" /></div>
> +  </wiki:SearchResults>
> +</div>
>
>  </wiki:Tab>
>
>
> Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiContext.java
> URL:
> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiContext.java?rev=782495&r1=782494&r2=782495&view=diff
>
> ==============================================================================
> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiContext.java
> (original)
> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiContext.java Mon
> Jun  8 01:37:33 2009
> @@ -103,7 +103,7 @@
>     public static final String    COMMENT  = HandlerInfo.getHandlerInfo(
> EditActionBean.class, "comment" ).getRequestContext();
>
>     /** User is searching for content. */
> -    public static final String    FIND     = HandlerInfo.getHandlerInfo(
> SearchActionBean.class, "find" ).getRequestContext();
> +    public static final String    FIND     = HandlerInfo.getHandlerInfo(
> SearchActionBean.class, "search" ).getRequestContext();
>
>     /** User wishes to create a new group */
>     public static final String    CREATE_GROUP =
> HandlerInfo.getHandlerInfo( GroupActionBean.class, "create"
> ).getRequestContext();
>
> Modified:
> incubator/jspwiki/trunk/src/java/org/apache/wiki/action/SearchActionBean.java
> URL:
> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/action/SearchActionBean.java?rev=782495&r1=782494&r2=782495&view=diff
>
> ==============================================================================
> ---
> incubator/jspwiki/trunk/src/java/org/apache/wiki/action/SearchActionBean.java
> (original)
> +++
> incubator/jspwiki/trunk/src/java/org/apache/wiki/action/SearchActionBean.java
> Mon Jun  8 01:37:33 2009
> @@ -21,18 +21,191 @@
>
>  package org.apache.wiki.action;
>
> -import org.apache.wiki.ui.stripes.WikiRequestContext;
> +import java.util.ArrayList;
> +import java.util.Collection;
> +import java.util.Collections;
> +import java.util.List;
>
>  import net.sourceforge.stripes.action.*;
> +import net.sourceforge.stripes.ajax.JavaScriptResolution;
> +
> +import org.apache.wiki.WikiEngine;
> +import org.apache.wiki.api.WikiPage;
> +import org.apache.wiki.auth.AuthorizationManager;
> +import org.apache.wiki.auth.permissions.PagePermission;
> +import org.apache.wiki.log.Logger;
> +import org.apache.wiki.log.LoggerFactory;
> +import org.apache.wiki.search.SearchResult;
> +import org.apache.wiki.ui.stripes.WikiRequestContext;
>
> +/**
> + * Searches the WikiPage collection for a given wiki.
> + */
>  @UrlBinding( "/Search.jsp" )
>  public class SearchActionBean extends AbstractActionBean
>  {
> +    private Logger log = LoggerFactory.getLogger("JSPWikiSearch");
> +
> +    public static final Collection<SearchResult> NO_RESULTS =
> Collections.emptyList();
> +
> +    private Collection<SearchResult> m_results = NO_RESULTS;
> +
> +    private String m_query = null;
> +
> +    private int m_maxItems = 20;
> +
> +    private int m_start = 0;
> +
> +    private boolean m_details = false;
> +
> +    public boolean getDetails()
> +    {
> +        return m_details;
> +    }
> +
> +    /**
> +     * Sets the search results so that details for each result are
> displayed.
> +     * @param details whether details should be displayed
> +     */
> +    public void setDetails( boolean details )
> +    {
> +        m_details = details;
> +    }
> +
> +    public int getMaxItems()
> +    {
> +        return m_maxItems;
> +    }
> +
> +    public void setMaxItems( int maxItems )
> +    {
> +        m_maxItems = maxItems;
> +    }
> +
> +    public int getStart()
> +    {
> +        return m_start;
> +    }
> +
> +    public void setStart( int start )
> +    {
> +        m_start = start;
> +    }
> +
> +    /**
> +     * Returns the query string for the search.
> +     *
> +     * @return the query string
> +     */
> +    public String getQuery()
> +    {
> +        return m_query;
> +    }
> +
> +    /**
> +     * Returns the results of the search.
> +     *
> +     * @return the results
> +     */
> +    public Collection<SearchResult> getResults()
> +    {
> +        return m_results;
> +    }
> +
> +    /**
> +     * Returns the number of items returned by the current search.
> +     * @return the number of items
> +     */
> +    public int getResultsCount()
> +    {
> +        return m_results.size();
> +    }
> +
> +    /**
> +     * Performs a search and returns the results as a list. For a given
> WikiPage to
> +     * be included in the results, the user must have permission to view
> it.
> +     * If the underlying providers encounter an abnormal IOException or
> other error,
> +     * it will be added to the ActionBeanContext's validation messages
> collection.
> +     * @param query the query
> +     * @return the results
> +     */
> +    private List<SearchResult> doSearch( String query )
> +    {
> +        log.info("Searching with query '"+ query + "'.");
> +        WikiEngine engine = getContext().getEngine();
> +        AuthorizationManager mgr = engine.getAuthorizationManager();
> +
> +        //
> +        //  Filter down to only those that we actually have a permission
> to view
> +        //
> +        List<SearchResult> filteredResults = new
> ArrayList<SearchResult>();
> +        try
> +        {
> +            List<SearchResult> results = engine.findPages( query );
> +            for( SearchResult result : results )
> +            {
> +                WikiPage page = result.getPage();
> +                PagePermission permission = new PagePermission( page,
> PagePermission.VIEW_ACTION );
> +                try
> +                {
> +                    if( mgr.checkPermission(
> getContext().getWikiSession(), permission ) )
> +                    {
> +                        filteredResults.add( result );
> +                    }
> +                }
> +                catch( Exception e ) { log.error( "Searching for page " +
> page, e ); }
> +            }
> +        }
> +        catch( Exception e )
> +        {
> +            log.debug( "Could not search using query '" + query + "'.", e
> );
> +            Message message = new SimpleMessage( e.getMessage() );
> +            getContext().getMessages().add( message );
> +            e.printStackTrace();
> +        }
> +        return filteredResults;
> +    }
> +
> +    /**
> +     * Sets the query string for the search.
> +     *
> +     * @param query the query string
> +     */
> +    public void setQuery( String query )
> +    {
> +        m_query = query;
> +    }
> +
> +    /**
> +     * Searches the wiki using the query string set for this
> +     * ActionBean. Search results are made available to callers via the
> +     * {@link #getResults()} method (and EL expression
> +     * <code>$wikiActionBean.results</code>).
> +     *
> +     * @return always returns a {@link ForwardResolution} to
> +     *         <code>/Search.jsp</code>.
> +     */
>     @DefaultHandler
> -    @HandlesEvent( "find" )
> +    @HandlesEvent( "search" )
>     @WikiRequestContext( "find" )
> -    public Resolution view()
> +    public Resolution search()
>     {
> +        m_results = m_query == null ? NO_RESULTS : doSearch( m_query );
>         return new ForwardResolution( "/Search.jsp" );
>     }
> +
> +    /**
> +     * Using AJAX, searches a specified wiki space using the query string
> set for this
> +     * ActionBean. Results are streamed back to the client as an array of
> JSON-encoded
> +     * SearchResult objects.
> +     *
> +     * @return always returns a {@link JavaScriptResolution} containing
> the
> +     * results; this may be a zero-length array
> +     */
> +    @HandlesEvent( "ajaxSearch" )
> +    public Resolution ajaxSearch()
> +    {
> +        m_results = m_query == null ? NO_RESULTS : doSearch( m_query );
> +        return new JavaScriptResolution( m_results );
> +    }
>  }
>
> Modified:
> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IfNoSearchResultsTag.java
> URL:
> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IfNoSearchResultsTag.java?rev=782495&r1=782494&r2=782495&view=diff
>
> ==============================================================================
> ---
> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IfNoSearchResultsTag.java
> (original)
> +++
> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IfNoSearchResultsTag.java
> Mon Jun  8 01:37:33 2009
> @@ -22,8 +22,8 @@
>
>  import java.io.IOException;
>  import java.util.Collection;
> -import javax.servlet.jsp.PageContext;
>
> +import org.apache.wiki.action.SearchActionBean;
>  import org.apache.wiki.search.SearchResult;
>
>  /**
> @@ -36,17 +36,18 @@
>  {
>     private static final long serialVersionUID = 0L;
>
> -    @SuppressWarnings("unchecked")
>     public final int doWikiStartTag()
>         throws IOException
>     {
> -        Collection<SearchResult> list =
> (Collection<SearchResult>)pageContext.getAttribute( "searchresults",
> -
>  PageContext.REQUEST_SCOPE );
> -        if( list == null || list.size() == 0 )
> -        {
> -            return EVAL_BODY_INCLUDE;
> +        if ( m_wikiActionBean != null && m_wikiActionBean instanceof
> SearchActionBean )
> +        {
> +            boolean emptyQuery =
> ((SearchActionBean)m_wikiActionBean).getQuery() == null;
> +            Collection<SearchResult> results =
> ((SearchActionBean)m_wikiActionBean).getResults();
> +            if ( emptyQuery || results.size() > 0 )
> +            {
> +                return SKIP_BODY;
> +            }
>         }
> -
> -        return SKIP_BODY;
> +        return EVAL_BODY_INCLUDE;
>     }
>  }
>
> Modified:
> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultIteratorTag.java
> URL:
> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultIteratorTag.java?rev=782495&r1=782494&r2=782495&view=diff
>
> ==============================================================================
> ---
> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultIteratorTag.java
> (original)
> +++
> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultIteratorTag.java
> Mon Jun  8 01:37:33 2009
> @@ -20,12 +20,12 @@
>  */
>  package org.apache.wiki.tags;
>
> -import java.util.ArrayList;
>  import java.util.Collection;
>
> -import javax.servlet.jsp.PageContext;
> -
> +import org.apache.wiki.action.SearchActionBean;
> +import org.apache.wiki.action.WikiActionBean;
>  import org.apache.wiki.search.SearchResult;
> +import org.apache.wiki.ui.stripes.WikiInterceptor;
>
>  /**
>  * Iterator tag for the current search results, as identified by a
> @@ -36,19 +36,17 @@
>     private static final long serialVersionUID = 1L;
>
>     /**
> -     * \ Returns the list of SearchResults to iterate over.
> +     * Returns the list of SearchResults to iterate over.
>      */
>     @Override
> -    @SuppressWarnings( "unchecked" )
>     protected Collection<SearchResult> initItems()
>     {
> -        Collection<SearchResult> results = (Collection<SearchResult>)
> pageContext.getAttribute( "searchresults",
> -
>                      PageContext.REQUEST_SCOPE );
> -        if( results == null )
> +        WikiActionBean actionBean = WikiInterceptor.findActionBean(
> pageContext );
> +        if ( actionBean != null && actionBean instanceof SearchActionBean
> )
>         {
> -            return new ArrayList<SearchResult>();
> +            return ((SearchActionBean)actionBean).getResults();
>         }
> -        return results;
> +        return SearchActionBean.NO_RESULTS;
>     }
>
>     /**
>
> Modified:
> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsSizeTag.java
> URL:
> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsSizeTag.java?rev=782495&r1=782494&r2=782495&view=diff
>
> ==============================================================================
> ---
> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsSizeTag.java
> (original)
> +++
> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsSizeTag.java
> Mon Jun  8 01:37:33 2009
> @@ -22,8 +22,8 @@
>
>  import java.io.IOException;
>  import java.util.Collection;
> -import javax.servlet.jsp.PageContext;
>
> +import org.apache.wiki.action.SearchActionBean;
>  import org.apache.wiki.search.SearchResult;
>
>  /**
> @@ -37,17 +37,14 @@
>  {
>     private static final long serialVersionUID = 0L;
>
> -    @SuppressWarnings("unchecked")
>     public final int doWikiStartTag()
>         throws IOException
>     {
> -        Collection<SearchResult> list =
> (Collection<SearchResult>)pageContext.getAttribute( "searchresults",
> -
>  PageContext.REQUEST_SCOPE );
> -        if( list != null )
> +        if ( m_wikiActionBean != null && m_wikiActionBean instanceof
> SearchActionBean )
>         {
> -            pageContext.getOut().print( list.size() );
> +            Collection<SearchResult> results =
> ((SearchActionBean)m_wikiActionBean).getResults();
> +            pageContext.getOut().print( results.size() );
>         }
> -
>         return SKIP_BODY;
>     }
>  }
>
> Modified:
> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsTag.java
> URL:
> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsTag.java?rev=782495&r1=782494&r2=782495&view=diff
>
> ==============================================================================
> ---
> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsTag.java
> (original)
> +++
> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsTag.java
> Mon Jun  8 01:37:33 2009
> @@ -21,10 +21,10 @@
>  package org.apache.wiki.tags;
>
>  import java.io.IOException;
> -import java.util.Collection;
> +
>  import javax.servlet.jsp.PageContext;
>
> -import org.apache.wiki.search.SearchResult;
> +import org.apache.wiki.action.SearchActionBean;
>
>  /**
>  *  Includes the body content, if there are any search results.
> @@ -36,16 +36,16 @@
>  {
>     private static final long serialVersionUID = 0L;
>
> -    @SuppressWarnings("unchecked")
>     public final int doWikiStartTag()
>         throws IOException
>     {
> -        Collection<SearchResult> list =
> (Collection<SearchResult>)pageContext.getAttribute( "searchresults",
> -
>  PageContext.REQUEST_SCOPE );
> -
> -        if( list != null )
> +        if ( m_wikiActionBean != null && m_wikiActionBean instanceof
> SearchActionBean )
>         {
> -            return EVAL_BODY_INCLUDE;
> +            boolean emptyQuery =
> ((SearchActionBean)m_wikiActionBean).getQuery() == null;
> +            if ( !emptyQuery )
> +            {
> +                return EVAL_BODY_INCLUDE;
> +            }
>         }
>
>         String message = (String)pageContext.getAttribute( "err",
>
>
>

Re: svn commit: r782495 - in /incubator/jspwiki/trunk/src: WebContent/ WebContent/scripts/ WebContent/templates/default/ java/org/apache/wiki/ java/org/apache/wiki/action/ java/org/apache/wiki/tags/

Posted by Andrew Jaquith <an...@gmail.com>.
Yah, true. This is not exactly at the top of the priorities list. :)  
But it would be easier to maintain the JS code if it were less  
monlithic. <musing/>...

On Jun 9, 2009, at 15:30, Janne Jalkanen <ja...@ecyrd.com>  
wrote:

>
> We compress the files anyway, so it could be done in the same ant  
> task. The unfortunate side-effect would be that if the logical  
> layout breaks from the deployment layout, it becomes difficult to  
> deploy JSPWiki directly from inside Eclipse. Which would be odd  
> considering all the trouble we went through enabling that  
> functionality.
>
> So concatenation might actually make development more difficult,  
> rather than easier.
>
> /Janne
>
> On 9 Jun 2009, at 02:59, Andrew Jaquith wrote:
>
>> There is a bigger issue here, too:
>>
>> I find ithard to comprehend how the JS code is organized. One  
>> suggestion I was going to make was that we chop the js-common file  
>> into smaller files for each logical group of funtionality (e.g.  
>> search.js), then concatenate it all together at build time  
>> (jspwiki.js). Thanks to Ant, this would be pretty easy, and would  
>> make the JS easier to understand and maintain.
>>
>> +1 for Janne's idea, also. The function signature would need an  
>> action URL, event name, array of parameters and a callback funtion.  
>> Pretty much just like Janne's example. :)
>>
>> Andrew
>>
>>
>> On Jun 8, 2009, at 15:53, Janne Jalkanen <ja...@ecyrd.com>  
>> wrote:
>>
>>>
>>> Reminds me - the JS code used to call Ajax routines is  
>>> disgustingly loathsome and makes my eyes bleed and my stomach  
>>> retch.  Can we upgrade to a newer Mootools lib (1.2.2, I think)  
>>> and switch to Request.JSON and create a JSONFactory or an  
>>> extension for creating our AJAX requests?
>>>
>>> Something like wiki.json( "Search", "ajaxSearch", { param1 :  
>>> value1, ... }, callback(resultobj,resulttext) ); would be nice.  
>>> This would construct the URL to SearchActionBean, method  
>>> ajaxSearch, with the given params.
>>>
>>> /Janne
>>>
>>> On 8 Jun 2009, at 21:52, Andrew Jaquith wrote:
>>>
>>>> It will fix this one -- but only after we've hooked it up to the
>>>> client JavaScript. Should not take long.
>>>>
>>>> On Mon, Jun 8, 2009 at 2:44 PM, Harry  
>>>> Metske<ha...@gmail.com> wrote:
>>>>> Andrew,
>>>>>
>>>>> should this patch have fixed
>>>>> https://issues.apache.org/jira/browse/JSPWIKI-510 (only for 3.0  
>>>>> of course) ?
>>>>>
>>>>> Harry
>>>>>
>>>>> 2009/6/8 <aj...@apache.org>
>>>>>
>>>>>> Author: ajaquith
>>>>>> Date: Mon Jun  8 01:37:33 2009
>>>>>> New Revision: 782495
>>>>>>
>>>>>> URL: http://svn.apache.org/viewvc?rev=782495&view=rev
>>>>>> Log:
>>>>>> Search.jsp migrated to Stripes. SearchActionBean now provides  
>>>>>> searching
>>>>>> logic, including an ajaxSearch() method that filters results  
>>>>>> correctly (this
>>>>>> is not hooked up to the client JavaScript yet, but it should be
>>>>>> straightforward to do). Still some i18n cleanup to do.
>>>>>>
>>>>>> Modified:
>>>>>> incubator/jspwiki/trunk/src/WebContent/Search.jsp
>>>>>> incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-common.js
>>>>>> incubator/jspwiki/trunk/src/WebContent/templates/default/ 
>>>>>> FindContent.jsp
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiContext.java
>>>>>>
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/action/ 
>>>>>> SearchActionBean.java
>>>>>>
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>> IfNoSearchResultsTag.java
>>>>>>
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>> SearchResultIteratorTag.java
>>>>>>
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>> SearchResultsSizeTag.java
>>>>>>
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>> SearchResultsTag.java
>>>>>>
>>>>>> Modified: incubator/jspwiki/trunk/src/WebContent/Search.jsp
>>>>>> URL:
>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/WebContent/Search.jsp?rev=782495&r1=782494&r2=782495&view=diff
>>>>>>
>>>>>> === 
>>>>>> === 
>>>>>> === 
>>>>>> === 
>>>>>> === 
>>>>>> ===============================================================
>>>>>> --- incubator/jspwiki/trunk/src/WebContent/Search.jsp (original)
>>>>>> +++ incubator/jspwiki/trunk/src/WebContent/Search.jsp Mon Jun   
>>>>>> 8 01:37:33
>>>>>> 2009
>>>>>> @@ -18,108 +18,12 @@
>>>>>>  specific language governing permissions and limitations
>>>>>>  under the License.
>>>>>> --%>
>>>>>> -<%@ page import="org.apache.wiki.log.Logger" %>
>>>>>> -<%@ page import="org.apache.wiki.log.LoggerFactory" %>
>>>>>> -<%@ page import="org.apache.wiki.*" %>
>>>>>> -<%@ page import="org.apache.wiki.auth.*" %>
>>>>>> -<%@ page import="org.apache.wiki.auth.permissions.*" %>
>>>>>> -<%@ page import="java.util.*" %>
>>>>>> +<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld"  
>>>>>> prefix="s" %>
>>>>>> <%@ page errorPage="/Error.jsp" %>
>>>>>> -<%@ page import="org.apache.wiki.search.*" %>
>>>>>> -<%@ taglib uri="http://jakarta.apache.org/jspwiki.tld"  
>>>>>> prefix="wiki" %>
>>>>>> -<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld"
>>>>>> prefix="stripes" %>
>>>>>> -<%@ page import="org.apache.wiki.util.TextUtil" %>
>>>>>> -<%@ page import="org.apache.wiki.api.WikiPage" %>
>>>>>> -<stripes:useActionBean  
>>>>>> beanclass="org.apache.wiki.action.SearchActionBean"
>>>>>> event="find" id="wikiActionBean" />
>>>>>> +<s:useActionBean  
>>>>>> beanclass="org.apache.wiki.action.SearchActionBean"
>>>>>> event="search" executeResolution="true" id="wikiActionBean" />
>>>>>> +<s:layout-render name="${templates['DefaultLayout.jsp']}">
>>>>>> +  <s:layout-component name="content">
>>>>>> +      <jsp:include page="${templates['FindContent.jsp']}" />
>>>>>> +  </s:layout-component>
>>>>>> +</s:layout-render>
>>>>>>
>>>>>> -<%!
>>>>>> -    Logger log = LoggerFactory.getLogger("JSPWikiSearch");
>>>>>> -%>
>>>>>> -
>>>>>> -<%
>>>>>> -    WikiEngine wiki =  
>>>>>> WikiEngine.getInstance( getServletConfig() );
>>>>>> -    // Create wiki context and check for authorization
>>>>>> -    WikiContext wikiContext = wiki.createContext( request,
>>>>>> WikiContext.FIND );
>>>>>> -    String pagereq = wikiContext.getPage().getName();
>>>>>> -
>>>>>> -    // Get the search results
>>>>>> -    Collection list = null;
>>>>>> -    String query = request.getParameter( "query");
>>>>>> -    String go    = request.getParameter("go");
>>>>>> -
>>>>>> -    if( query != null )
>>>>>> -    {
>>>>>> -        log.info("Searching for string "+query);
>>>>>> -
>>>>>> -        try
>>>>>> -        {
>>>>>> -            list = wiki.findPages( query );
>>>>>> -
>>>>>> -            //
>>>>>> -            //  Filter down to only those that we actually  
>>>>>> have a
>>>>>> permission to view
>>>>>> -            //
>>>>>> -            AuthorizationManager mgr =  
>>>>>> wiki.getAuthorizationManager();
>>>>>> -
>>>>>> -            ArrayList filteredList = new ArrayList();
>>>>>> -
>>>>>> -            for( Iterator i = list.iterator(); i.hasNext(); )
>>>>>> -            {
>>>>>> -                SearchResult r = (SearchResult)i.next();
>>>>>> -
>>>>>> -                WikiPage p = r.getPage();
>>>>>> -
>>>>>> -                PagePermission pp = new PagePermission( p,
>>>>>> PagePermission.VIEW_ACTION );
>>>>>> -
>>>>>> -                try
>>>>>> -                {
>>>>>> -                     
>>>>>> if( mgr.checkPermission( wikiContext.getWikiSession(),
>>>>>> pp ) )
>>>>>> -                    {
>>>>>> -                        filteredList.add( r );
>>>>>> -                    }
>>>>>> -                }
>>>>>> -                catch( Exception e ) { log.error( "Searching  
>>>>>> for page "+p,
>>>>>> e ); }
>>>>>> -            }
>>>>>> -
>>>>>> -            pageContext.setAttribute( "searchresults",
>>>>>> -                                      filteredList,
>>>>>> -                                       
>>>>>> PageContext.REQUEST_SCOPE );
>>>>>> -        }
>>>>>> -        catch( Exception e )
>>>>>> -        {
>>>>>> -             
>>>>>> wikiContext.getWikiSession().addMessage( e.getMessage() );
>>>>>> -        }
>>>>>> -
>>>>>> -        query = TextUtil.replaceEntities( query );
>>>>>> -
>>>>>> -        pageContext.setAttribute( "query",
>>>>>> -                                  query,
>>>>>> -                                  PageContext.REQUEST_SCOPE );
>>>>>> -
>>>>>> -        //
>>>>>> -        //  Did the user click on "go"?
>>>>>> -        //
>>>>>> -        if( go != null )
>>>>>> -        {
>>>>>> -            if( list != null && list.size() > 0 )
>>>>>> -            {
>>>>>> -                SearchResult sr = (SearchResult)  
>>>>>> list.iterator().next();
>>>>>> -
>>>>>> -                WikiPage wikiPage = sr.getPage();
>>>>>> -
>>>>>> -                String url =  
>>>>>> wikiContext.getViewURL( wikiPage.getName() );
>>>>>> -
>>>>>> -                response.sendRedirect( url );
>>>>>> -
>>>>>> -                return;
>>>>>> -            }
>>>>>> -        }
>>>>>> -    }
>>>>>> -
>>>>>> -    // Set the content type and include the response content
>>>>>> -    response.setContentType("text/html;
>>>>>> charset="+wiki.getContentEncoding() );
>>>>>> -    String contentPage =  
>>>>>> wiki.getTemplateManager().findJSP( pageContext,
>>>>>> -
>>>>>> wikiContext.getTemplate(),
>>>>>> -
>>>>>> "ViewTemplate.jsp" );
>>>>>> -%><wiki:Include page="<%=contentPage%>" /><%
>>>>>> -    log.debug("SEARCH COMPLETE");
>>>>>> -%>
>>>>>>
>>>>>> Modified: incubator/jspwiki/trunk/src/WebContent/scripts/ 
>>>>>> jspwiki-common.js
>>>>>> URL:
>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-common.js?rev=782495&r1=782494&r2=782495&view=diff
>>>>>>
>>>>>> === 
>>>>>> === 
>>>>>> === 
>>>>>> === 
>>>>>> === 
>>>>>> ===============================================================
>>>>>> --- incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki- 
>>>>>> common.js
>>>>>> (original)
>>>>>> +++ incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki- 
>>>>>> common.js Mon
>>>>>> Jun  8 01:37:33 2009
>>>>>> @@ -931,9 +931,9 @@
>>>>>>                     if (option.value == match) option.selected  
>>>>>> = true;
>>>>>>             });
>>>>>>
>>>>>> -               new Ajax(Wiki.TemplateUrl+'AJAXSearch.jsp', {
>>>>>> -                       postBody: $ 
>>>>>> ('searchform2').toQueryString(),
>>>>>> -                       update: 'searchResult2',
>>>>>> +               new Ajax(Wiki.BasePath+'Search.action', {
>>>>>> +                       postBody:
>>>>>> "ajaxSearch=&"+$('searchform2').toQueryString(),
>>>>>> +                       update: 'searchResult2',
>>>>>>                     method: 'post',
>>>>>>                     onComplete: function() {
>>>>>>                             $('spin').hide();
>>>>>>
>>>>>> Modified:
>>>>>> incubator/jspwiki/trunk/src/WebContent/templates/default/ 
>>>>>> FindContent.jsp
>>>>>> URL:
>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/WebContent/templates/default/FindContent.jsp?rev=782495&r1=782494&r2=782495&view=diff
>>>>>>
>>>>>> === 
>>>>>> === 
>>>>>> === 
>>>>>> === 
>>>>>> === 
>>>>>> ===============================================================
>>>>>> ---
>>>>>> incubator/jspwiki/trunk/src/WebContent/templates/default/ 
>>>>>> FindContent.jsp
>>>>>> (original)
>>>>>> +++
>>>>>> incubator/jspwiki/trunk/src/WebContent/templates/default/ 
>>>>>> FindContent.jsp Mon
>>>>>> Jun  8 01:37:33 2009
>>>>>> @@ -27,24 +27,18 @@
>>>>>> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
>>>>>> <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
>>>>>> <%@ page import="javax.servlet.jsp.jstl.fmt.*" %>
>>>>>> -<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld"
>>>>>> prefix="stripes" %>
>>>>>> +<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld"  
>>>>>> prefix="s" %>
>>>>>>
>>>>>> <wiki:TabbedSection>
>>>>>> <wiki:Tab id="findcontent" titleKey="find.tab" accesskey="s">
>>>>>>
>>>>>> -<form action="<wiki:Link format='url' jsp='Search.jsp'/>"
>>>>>> -       class="wikiform"
>>>>>> -          id="searchform2"
>>>>>> -         accept-charset="<wiki:ContentEncoding/>">
>>>>>> -
>>>>>> +<s:form beanclass="org.apache.wiki.action.SearchActionBean"
>>>>>> class="wikiform"
>>>>>> +    id="searchform2" acceptcharset="UTF-8">
>>>>>> +
>>>>>> <h4><fmt:message key="find.input" /></h4>
>>>>>> <p>
>>>>>> -    <input type="text"
>>>>>> -           name="query" id="query2"
>>>>>> -          value="<c:out value='${query}'/>"
>>>>>> -           size="32" />
>>>>>> -
>>>>>> -    <input type="checkbox" name="details" id="details" <c:if
>>>>>> test='${param.details == "on"}'>checked='checked'</c:if> />
>>>>>> +    <s:text name="query" id="query2" size="32" />
>>>>>> +    <s:checkbox name="details" id="details" />
>>>>>>  <fmt:message key="find.details" />
>>>>>>
>>>>>>  <select name="scope" id="scope">
>>>>>> @@ -55,16 +49,83 @@
>>>>>>    <option value="attachment:" <c:if test='${param.scope eq
>>>>>> "attachment:"}'>selected="selected"</c:if> ><fmt:message
>>>>>> key='find.scope.attach' /></option>
>>>>>>  </select>
>>>>>>
>>>>>> -       <input type="submit" name="ok" id="ok"  
>>>>>> value="<fmt:message
>>>>>> key="find.submit.find" />" />
>>>>>> -       <input type="submit" name="go" id="go"  
>>>>>> value="<fmt:message
>>>>>> key="find.submit.go" />" />
>>>>>> -    <input type="hidden" name="start" id="start" value="0" />
>>>>>> -    <input type="hidden" name="maxitems" id="maxitems"  
>>>>>> value="20" />
>>>>>> +    <s:submit name="search" id="ok" value="<fmt:message
>>>>>> key='find.submit.find' />" />
>>>>>> +    <s:submit name="go" id="go" value="<fmt:message  
>>>>>> key='find.submit.go'
>>>>>> />" />
>>>>>> +    <s:hidden name="start" id="start" value="0" />
>>>>>> +    <s:hidden name="maxItems" id="maxitems" value="20" />
>>>>>>
>>>>>>  <span id="spin" class="spin"
>>>>>> style="position:absolute;display:none;"></span>
>>>>>> </p>
>>>>>> -</form>
>>>>>> +</s:form>
>>>>>> +
>>>>>> +<div id="searchResult2">
>>>>>> +  <wiki:SearchResults>
>>>>>> +
>>>>>> +    <h4><fmt:message  
>>>>>> key="find.heading.results"><fmt:param><c:out
>>>>>> value="${wikiActionBean.query}" /></fmt:param></fmt:message></h4>
>>>>>> +    <p>
>>>>>> +      <fmt:message key="find.externalsearch" />
>>>>>> +      <a class="external" href="http://www.google.com/search? 
>>>>>> q=<c:out
>>>>>> value='${wikiActionBean.query}' />" title="Google Search '<c:out
>>>>>> value='${wikiActionBean.query}' />'" target="_blank">Google</ 
>>>>>> a><img
>>>>>> class="outlink" src="images/out.png" alt="" />
>>>>>> +      |
>>>>>> +      <a class="external" href="
>>>>>> http://en.wikipedia.org/wiki/Special:Search?search=<c:out
>>>>>> value='${wikiActionBean.query}' />" title="Wikipedia Search  
>>>>>> '<c:out
>>>>>> value='${wikiActionBean.query}' />'" target="_blank">Wikipedia</ 
>>>>>> a><img
>>>>>> class="outlink" src="images/out.png" alt="" />
>>>>>> +    </p>
>>>>>> +
>>>>>> +    <wiki:SetPagination start="${wikiActionBean.start}"
>>>>>> total="${wikiActionBean.resultsCount}" pagesize="20" maxlinks="9"
>>>>>> fmtkey="info.pagination" onclick="$('start').value=%s;
>>>>>> SearchBox.runfullsearch();" />
>>>>>> +
>>>>>> +    <div class="graphBars">
>>>>>> +      <div class="zebra-table">
>>>>>> +        <table class="wikitable">
>>>>>> +
>>>>>> +          <tr>
>>>>>> +             <th align="left"><fmt:message  
>>>>>> key="find.results.page" /></th>
>>>>>> +             <th align="left"><fmt:message  
>>>>>> key="find.results.score"
>>>>>> /></th>
>>>>>> +          </tr>
>>>>>> +
>>>>>> +          <wiki:SearchResultIterator id="searchref"
>>>>>> start="${wikiActionBean.start}" maxItems="$ 
>>>>>> {wikiActionBean.maxItems}">
>>>>>> +          <tr>
>>>>>> +            <td><wiki:LinkTo><wiki:PageName/></wiki:LinkTo></td>
>>>>>> +            <td><span class="gBar"><%= searchref.getScore()  
>>>>>> %></span></td>
>>>>>> +          </tr>
>>>>>> +
>>>>>> +          <c:if test="${wikiActionBean.details == 'true'}">
>>>>>> +  <%
>>>>>> +            String[] contexts = searchref.getContexts();
>>>>>> +            if( (contexts != null) && (contexts.length > 0) )
>>>>>> +            {
>>>>>> +  %>
>>>>>> +          <tr class="odd">
>>>>>> +            <td colspan="2">
>>>>>> +              <div class="fragment">
>>>>>> +  <%
>>>>>> +              for (int i = 0; i < contexts.length; i++)
>>>>>> +              {
>>>>>> +  %>
>>>>>> +                <%= (i > 0 ) ? "<span  
>>>>>> class='fragment_ellipsis'> ...
>>>>>> </span>" : ""  %>
>>>>>> +                <%= contexts[i]  %>
>>>>>> +  <%
>>>>>> +              }
>>>>>> +  %>
>>>>>> +               </div>
>>>>>> +             </td>
>>>>>> +           </tr>
>>>>>> +  <%
>>>>>> +            }
>>>>>> +  %>
>>>>>> +          </c:if><%-- details --%>
>>>>>> +        </wiki:SearchResultIterator>
>>>>>> +
>>>>>> +        <wiki:IfNoSearchResults>
>>>>>> +          <tr>
>>>>>> +            <td class="nosearchresult" colspan="2"><fmt:message
>>>>>> key="find.noresults" /></td>
>>>>>> +          </tr>
>>>>>> +        </wiki:IfNoSearchResults>
>>>>>> +
>>>>>> +        </table>
>>>>>> +      </div>
>>>>>> +    </div>
>>>>>> +    ${pagination}
>>>>>>
>>>>>> -<div id="searchResult2"><wiki:Include page="AJAXSearch.jsp" / 
>>>>>> ></div>
>>>>>> +  </wiki:SearchResults>
>>>>>> +</div>
>>>>>>
>>>>>> </wiki:Tab>
>>>>>>
>>>>>>
>>>>>> Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/ 
>>>>>> WikiContext.java
>>>>>> URL:
>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiContext.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>>>
>>>>>> === 
>>>>>> === 
>>>>>> === 
>>>>>> === 
>>>>>> === 
>>>>>> ===============================================================
>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/ 
>>>>>> WikiContext.java
>>>>>> (original)
>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/ 
>>>>>> WikiContext.java Mon
>>>>>> Jun  8 01:37:33 2009
>>>>>> @@ -103,7 +103,7 @@
>>>>>>  public static final String    COMMENT  =  
>>>>>> HandlerInfo.getHandlerInfo(
>>>>>> EditActionBean.class, "comment" ).getRequestContext();
>>>>>>
>>>>>>  /** User is searching for content. */
>>>>>> -    public static final String    FIND     =  
>>>>>> HandlerInfo.getHandlerInfo(
>>>>>> SearchActionBean.class, "find" ).getRequestContext();
>>>>>> +    public static final String    FIND     =  
>>>>>> HandlerInfo.getHandlerInfo(
>>>>>> SearchActionBean.class, "search" ).getRequestContext();
>>>>>>
>>>>>>  /** User wishes to create a new group */
>>>>>>  public static final String    CREATE_GROUP =
>>>>>> HandlerInfo.getHandlerInfo( GroupActionBean.class, "create"
>>>>>> ).getRequestContext();
>>>>>>
>>>>>> Modified:
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/action/ 
>>>>>> SearchActionBean.java
>>>>>> URL:
>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/action/SearchActionBean.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>>>
>>>>>> === 
>>>>>> === 
>>>>>> === 
>>>>>> === 
>>>>>> === 
>>>>>> ===============================================================
>>>>>> ---
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/action/ 
>>>>>> SearchActionBean.java
>>>>>> (original)
>>>>>> +++
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/action/ 
>>>>>> SearchActionBean.java
>>>>>> Mon Jun  8 01:37:33 2009
>>>>>> @@ -21,18 +21,191 @@
>>>>>>
>>>>>> package org.apache.wiki.action;
>>>>>>
>>>>>> -import org.apache.wiki.ui.stripes.WikiRequestContext;
>>>>>> +import java.util.ArrayList;
>>>>>> +import java.util.Collection;
>>>>>> +import java.util.Collections;
>>>>>> +import java.util.List;
>>>>>>
>>>>>> import net.sourceforge.stripes.action.*;
>>>>>> +import net.sourceforge.stripes.ajax.JavaScriptResolution;
>>>>>> +
>>>>>> +import org.apache.wiki.WikiEngine;
>>>>>> +import org.apache.wiki.api.WikiPage;
>>>>>> +import org.apache.wiki.auth.AuthorizationManager;
>>>>>> +import org.apache.wiki.auth.permissions.PagePermission;
>>>>>> +import org.apache.wiki.log.Logger;
>>>>>> +import org.apache.wiki.log.LoggerFactory;
>>>>>> +import org.apache.wiki.search.SearchResult;
>>>>>> +import org.apache.wiki.ui.stripes.WikiRequestContext;
>>>>>>
>>>>>> +/**
>>>>>> + * Searches the WikiPage collection for a given wiki.
>>>>>> + */
>>>>>> @UrlBinding( "/Search.jsp" )
>>>>>> public class SearchActionBean extends AbstractActionBean
>>>>>> {
>>>>>> +    private Logger log =  
>>>>>> LoggerFactory.getLogger("JSPWikiSearch");
>>>>>> +
>>>>>> +    public static final Collection<SearchResult> NO_RESULTS =
>>>>>> Collections.emptyList();
>>>>>> +
>>>>>> +    private Collection<SearchResult> m_results = NO_RESULTS;
>>>>>> +
>>>>>> +    private String m_query = null;
>>>>>> +
>>>>>> +    private int m_maxItems = 20;
>>>>>> +
>>>>>> +    private int m_start = 0;
>>>>>> +
>>>>>> +    private boolean m_details = false;
>>>>>> +
>>>>>> +    public boolean getDetails()
>>>>>> +    {
>>>>>> +        return m_details;
>>>>>> +    }
>>>>>> +
>>>>>> +    /**
>>>>>> +     * Sets the search results so that details for each result  
>>>>>> are
>>>>>> displayed.
>>>>>> +     * @param details whether details should be displayed
>>>>>> +     */
>>>>>> +    public void setDetails( boolean details )
>>>>>> +    {
>>>>>> +        m_details = details;
>>>>>> +    }
>>>>>> +
>>>>>> +    public int getMaxItems()
>>>>>> +    {
>>>>>> +        return m_maxItems;
>>>>>> +    }
>>>>>> +
>>>>>> +    public void setMaxItems( int maxItems )
>>>>>> +    {
>>>>>> +        m_maxItems = maxItems;
>>>>>> +    }
>>>>>> +
>>>>>> +    public int getStart()
>>>>>> +    {
>>>>>> +        return m_start;
>>>>>> +    }
>>>>>> +
>>>>>> +    public void setStart( int start )
>>>>>> +    {
>>>>>> +        m_start = start;
>>>>>> +    }
>>>>>> +
>>>>>> +    /**
>>>>>> +     * Returns the query string for the search.
>>>>>> +     *
>>>>>> +     * @return the query string
>>>>>> +     */
>>>>>> +    public String getQuery()
>>>>>> +    {
>>>>>> +        return m_query;
>>>>>> +    }
>>>>>> +
>>>>>> +    /**
>>>>>> +     * Returns the results of the search.
>>>>>> +     *
>>>>>> +     * @return the results
>>>>>> +     */
>>>>>> +    public Collection<SearchResult> getResults()
>>>>>> +    {
>>>>>> +        return m_results;
>>>>>> +    }
>>>>>> +
>>>>>> +    /**
>>>>>> +     * Returns the number of items returned by the current  
>>>>>> search.
>>>>>> +     * @return the number of items
>>>>>> +     */
>>>>>> +    public int getResultsCount()
>>>>>> +    {
>>>>>> +        return m_results.size();
>>>>>> +    }
>>>>>> +
>>>>>> +    /**
>>>>>> +     * Performs a search and returns the results as a list.  
>>>>>> For a given
>>>>>> WikiPage to
>>>>>> +     * be included in the results, the user must have  
>>>>>> permission to view
>>>>>> it.
>>>>>> +     * If the underlying providers encounter an abnormal  
>>>>>> IOException or
>>>>>> other error,
>>>>>> +     * it will be added to the ActionBeanContext's validation  
>>>>>> messages
>>>>>> collection.
>>>>>> +     * @param query the query
>>>>>> +     * @return the results
>>>>>> +     */
>>>>>> +    private List<SearchResult> doSearch( String query )
>>>>>> +    {
>>>>>> +        log.info("Searching with query '"+ query + "'.");
>>>>>> +        WikiEngine engine = getContext().getEngine();
>>>>>> +        AuthorizationManager mgr =  
>>>>>> engine.getAuthorizationManager();
>>>>>> +
>>>>>> +        //
>>>>>> +        //  Filter down to only those that we actually have a  
>>>>>> permission
>>>>>> to view
>>>>>> +        //
>>>>>> +        List<SearchResult> filteredResults = new
>>>>>> ArrayList<SearchResult>();
>>>>>> +        try
>>>>>> +        {
>>>>>> +            List<SearchResult> results =  
>>>>>> engine.findPages( query );
>>>>>> +            for( SearchResult result : results )
>>>>>> +            {
>>>>>> +                WikiPage page = result.getPage();
>>>>>> +                PagePermission permission = new  
>>>>>> PagePermission( page,
>>>>>> PagePermission.VIEW_ACTION );
>>>>>> +                try
>>>>>> +                {
>>>>>> +                    if( mgr.checkPermission(
>>>>>> getContext().getWikiSession(), permission ) )
>>>>>> +                    {
>>>>>> +                        filteredResults.add( result );
>>>>>> +                    }
>>>>>> +                }
>>>>>> +                catch( Exception e ) { log.error( "Searching  
>>>>>> for page " +
>>>>>> page, e ); }
>>>>>> +            }
>>>>>> +        }
>>>>>> +        catch( Exception e )
>>>>>> +        {
>>>>>> +            log.debug( "Could not search using query '" +  
>>>>>> query + "'.", e
>>>>>> );
>>>>>> +            Message message = new  
>>>>>> SimpleMessage( e.getMessage() );
>>>>>> +            getContext().getMessages().add( message );
>>>>>> +            e.printStackTrace();
>>>>>> +        }
>>>>>> +        return filteredResults;
>>>>>> +    }
>>>>>> +
>>>>>> +    /**
>>>>>> +     * Sets the query string for the search.
>>>>>> +     *
>>>>>> +     * @param query the query string
>>>>>> +     */
>>>>>> +    public void setQuery( String query )
>>>>>> +    {
>>>>>> +        m_query = query;
>>>>>> +    }
>>>>>> +
>>>>>> +    /**
>>>>>> +     * Searches the wiki using the query string set for this
>>>>>> +     * ActionBean. Search results are made available to  
>>>>>> callers via the
>>>>>> +     * {@link #getResults()} method (and EL expression
>>>>>> +     * <code>$wikiActionBean.results</code>).
>>>>>> +     *
>>>>>> +     * @return always returns a {@link ForwardResolution} to
>>>>>> +     *         <code>/Search.jsp</code>.
>>>>>> +     */
>>>>>>  @DefaultHandler
>>>>>> -    @HandlesEvent( "find" )
>>>>>> +    @HandlesEvent( "search" )
>>>>>>  @WikiRequestContext( "find" )
>>>>>> -    public Resolution view()
>>>>>> +    public Resolution search()
>>>>>>  {
>>>>>> +        m_results = m_query == null ? NO_RESULTS :  
>>>>>> doSearch( m_query );
>>>>>>      return new ForwardResolution( "/Search.jsp" );
>>>>>>  }
>>>>>> +
>>>>>> +    /**
>>>>>> +     * Using AJAX, searches a specified wiki space using the  
>>>>>> query string
>>>>>> set for this
>>>>>> +     * ActionBean. Results are streamed back to the client as  
>>>>>> an array of
>>>>>> JSON-encoded
>>>>>> +     * SearchResult objects.
>>>>>> +     *
>>>>>> +     * @return always returns a {@link JavaScriptResolution}  
>>>>>> containing
>>>>>> the
>>>>>> +     * results; this may be a zero-length array
>>>>>> +     */
>>>>>> +    @HandlesEvent( "ajaxSearch" )
>>>>>> +    public Resolution ajaxSearch()
>>>>>> +    {
>>>>>> +        m_results = m_query == null ? NO_RESULTS :  
>>>>>> doSearch( m_query );
>>>>>> +        return new JavaScriptResolution( m_results );
>>>>>> +    }
>>>>>> }
>>>>>>
>>>>>> Modified:
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>> IfNoSearchResultsTag.java
>>>>>> URL:
>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IfNoSearchResultsTag.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>>>
>>>>>> === 
>>>>>> === 
>>>>>> === 
>>>>>> === 
>>>>>> === 
>>>>>> ===============================================================
>>>>>> ---
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>> IfNoSearchResultsTag.java
>>>>>> (original)
>>>>>> +++
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>> IfNoSearchResultsTag.java
>>>>>> Mon Jun  8 01:37:33 2009
>>>>>> @@ -22,8 +22,8 @@
>>>>>>
>>>>>> import java.io.IOException;
>>>>>> import java.util.Collection;
>>>>>> -import javax.servlet.jsp.PageContext;
>>>>>>
>>>>>> +import org.apache.wiki.action.SearchActionBean;
>>>>>> import org.apache.wiki.search.SearchResult;
>>>>>>
>>>>>> /**
>>>>>> @@ -36,17 +36,18 @@
>>>>>> {
>>>>>>  private static final long serialVersionUID = 0L;
>>>>>>
>>>>>> -    @SuppressWarnings("unchecked")
>>>>>>  public final int doWikiStartTag()
>>>>>>      throws IOException
>>>>>>  {
>>>>>> -        Collection<SearchResult> list =
>>>>>> (Collection< 
>>>>>> SearchResult>)pageContext.getAttribute( "searchresults",
>>>>>> -
>>>>>> PageContext.REQUEST_SCOPE );
>>>>>> -        if( list == null || list.size() == 0 )
>>>>>> -        {
>>>>>> -            return EVAL_BODY_INCLUDE;
>>>>>> +        if ( m_wikiActionBean != null && m_wikiActionBean  
>>>>>> instanceof
>>>>>> SearchActionBean )
>>>>>> +        {
>>>>>> +            boolean emptyQuery =
>>>>>> ((SearchActionBean)m_wikiActionBean).getQuery() == null;
>>>>>> +            Collection<SearchResult> results =
>>>>>> ((SearchActionBean)m_wikiActionBean).getResults();
>>>>>> +            if ( emptyQuery || results.size() > 0 )
>>>>>> +            {
>>>>>> +                return SKIP_BODY;
>>>>>> +            }
>>>>>>      }
>>>>>> -
>>>>>> -        return SKIP_BODY;
>>>>>> +        return EVAL_BODY_INCLUDE;
>>>>>>  }
>>>>>> }
>>>>>>
>>>>>> Modified:
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>> SearchResultIteratorTag.java
>>>>>> URL:
>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultIteratorTag.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>>>
>>>>>> === 
>>>>>> === 
>>>>>> === 
>>>>>> === 
>>>>>> === 
>>>>>> ===============================================================
>>>>>> ---
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>> SearchResultIteratorTag.java
>>>>>> (original)
>>>>>> +++
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>> SearchResultIteratorTag.java
>>>>>> Mon Jun  8 01:37:33 2009
>>>>>> @@ -20,12 +20,12 @@
>>>>>> */
>>>>>> package org.apache.wiki.tags;
>>>>>>
>>>>>> -import java.util.ArrayList;
>>>>>> import java.util.Collection;
>>>>>>
>>>>>> -import javax.servlet.jsp.PageContext;
>>>>>> -
>>>>>> +import org.apache.wiki.action.SearchActionBean;
>>>>>> +import org.apache.wiki.action.WikiActionBean;
>>>>>> import org.apache.wiki.search.SearchResult;
>>>>>> +import org.apache.wiki.ui.stripes.WikiInterceptor;
>>>>>>
>>>>>> /**
>>>>>> * Iterator tag for the current search results, as identified by a
>>>>>> @@ -36,19 +36,17 @@
>>>>>>  private static final long serialVersionUID = 1L;
>>>>>>
>>>>>>  /**
>>>>>> -     * \ Returns the list of SearchResults to iterate over.
>>>>>> +     * Returns the list of SearchResults to iterate over.
>>>>>>   */
>>>>>>  @Override
>>>>>> -    @SuppressWarnings( "unchecked" )
>>>>>>  protected Collection<SearchResult> initItems()
>>>>>>  {
>>>>>> -        Collection<SearchResult> results =  
>>>>>> (Collection<SearchResult>)
>>>>>> pageContext.getAttribute( "searchresults",
>>>>>> -
>>>>>>                   PageContext.REQUEST_SCOPE );
>>>>>> -        if( results == null )
>>>>>> +        WikiActionBean actionBean =  
>>>>>> WikiInterceptor.findActionBean(
>>>>>> pageContext );
>>>>>> +        if ( actionBean != null && actionBean instanceof  
>>>>>> SearchActionBean
>>>>>> )
>>>>>>      {
>>>>>> -            return new ArrayList<SearchResult>();
>>>>>> +            return ((SearchActionBean)actionBean).getResults();
>>>>>>      }
>>>>>> -        return results;
>>>>>> +        return SearchActionBean.NO_RESULTS;
>>>>>>  }
>>>>>>
>>>>>>  /**
>>>>>>
>>>>>> Modified:
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>> SearchResultsSizeTag.java
>>>>>> URL:
>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsSizeTag.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>>>
>>>>>> === 
>>>>>> === 
>>>>>> === 
>>>>>> === 
>>>>>> === 
>>>>>> ===============================================================
>>>>>> ---
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>> SearchResultsSizeTag.java
>>>>>> (original)
>>>>>> +++
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>> SearchResultsSizeTag.java
>>>>>> Mon Jun  8 01:37:33 2009
>>>>>> @@ -22,8 +22,8 @@
>>>>>>
>>>>>> import java.io.IOException;
>>>>>> import java.util.Collection;
>>>>>> -import javax.servlet.jsp.PageContext;
>>>>>>
>>>>>> +import org.apache.wiki.action.SearchActionBean;
>>>>>> import org.apache.wiki.search.SearchResult;
>>>>>>
>>>>>> /**
>>>>>> @@ -37,17 +37,14 @@
>>>>>> {
>>>>>>  private static final long serialVersionUID = 0L;
>>>>>>
>>>>>> -    @SuppressWarnings("unchecked")
>>>>>>  public final int doWikiStartTag()
>>>>>>      throws IOException
>>>>>>  {
>>>>>> -        Collection<SearchResult> list =
>>>>>> (Collection< 
>>>>>> SearchResult>)pageContext.getAttribute( "searchresults",
>>>>>> -
>>>>>> PageContext.REQUEST_SCOPE );
>>>>>> -        if( list != null )
>>>>>> +        if ( m_wikiActionBean != null && m_wikiActionBean  
>>>>>> instanceof
>>>>>> SearchActionBean )
>>>>>>      {
>>>>>> -            pageContext.getOut().print( list.size() );
>>>>>> +            Collection<SearchResult> results =
>>>>>> ((SearchActionBean)m_wikiActionBean).getResults();
>>>>>> +            pageContext.getOut().print( results.size() );
>>>>>>      }
>>>>>> -
>>>>>>      return SKIP_BODY;
>>>>>>  }
>>>>>> }
>>>>>>
>>>>>> Modified:
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>> SearchResultsTag.java
>>>>>> URL:
>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsTag.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>>>
>>>>>> === 
>>>>>> === 
>>>>>> === 
>>>>>> === 
>>>>>> === 
>>>>>> ===============================================================
>>>>>> ---
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>> SearchResultsTag.java
>>>>>> (original)
>>>>>> +++
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>> SearchResultsTag.java
>>>>>> Mon Jun  8 01:37:33 2009
>>>>>> @@ -21,10 +21,10 @@
>>>>>> package org.apache.wiki.tags;
>>>>>>
>>>>>> import java.io.IOException;
>>>>>> -import java.util.Collection;
>>>>>> +
>>>>>> import javax.servlet.jsp.PageContext;
>>>>>>
>>>>>> -import org.apache.wiki.search.SearchResult;
>>>>>> +import org.apache.wiki.action.SearchActionBean;
>>>>>>
>>>>>> /**
>>>>>> *  Includes the body content, if there are any search results.
>>>>>> @@ -36,16 +36,16 @@
>>>>>> {
>>>>>>  private static final long serialVersionUID = 0L;
>>>>>>
>>>>>> -    @SuppressWarnings("unchecked")
>>>>>>  public final int doWikiStartTag()
>>>>>>      throws IOException
>>>>>>  {
>>>>>> -        Collection<SearchResult> list =
>>>>>> (Collection< 
>>>>>> SearchResult>)pageContext.getAttribute( "searchresults",
>>>>>> -
>>>>>> PageContext.REQUEST_SCOPE );
>>>>>> -
>>>>>> -        if( list != null )
>>>>>> +        if ( m_wikiActionBean != null && m_wikiActionBean  
>>>>>> instanceof
>>>>>> SearchActionBean )
>>>>>>      {
>>>>>> -            return EVAL_BODY_INCLUDE;
>>>>>> +            boolean emptyQuery =
>>>>>> ((SearchActionBean)m_wikiActionBean).getQuery() == null;
>>>>>> +            if ( !emptyQuery )
>>>>>> +            {
>>>>>> +                return EVAL_BODY_INCLUDE;
>>>>>> +            }
>>>>>>      }
>>>>>>
>>>>>>      String message = (String)pageContext.getAttribute( "err",
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>
>>>
>>>>>> /**
>>>>>> *  Includes the body content, if there are any search results.
>>>>>> @@ -36,16 +36,16 @@
>>>>>> {
>>>>>>  private static final long serialVersionUID = 0L;
>>>>>>
>>>>>> -    @SuppressWarnings("unchecked")
>>>>>>  public final int doWikiStartTag()
>>>>>>      throws IOException
>>>>>>  {
>>>>>> -        Collection<SearchResult> list =
>>>>>> (Collection< 
>>>>>> SearchResult>)pageContext.getAttribute( "searchresults",
>>>>>> -
>>>>>> PageContext.REQUEST_SCOPE );
>>>>>> -
>>>>>> -        if( list != null )
>>>>>> +        if ( m_wikiActionBean != null && m_wikiActionBean  
>>>>>> instanceof
>>>>>> SearchActionBean )
>>>>>>      {
>>>>>> -            return EVAL_BODY_INCLUDE;
>>>>>> +            boolean emptyQuery =
>>>>>> ((SearchActionBean)m_wikiActionBean).getQuery() == null;
>>>>>> +            if ( !emptyQuery )
>>>>>> +            {
>>>>>> +                return EVAL_BODY_INCLUDE;
>>>>>> +            }
>>>>>>      }
>>>>>>
>>>>>>      String message = (String)pageContext.getAttribute( "err",
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>
>
> "err",
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>
>>>
>>>>>> /**
>>>>>> *  Includes the body content, if there are any search results.
>>>>>> @@ -36,16 +36,16 @@
>>>>>> {
>>>>>>  private static final long serialVersionUID = 0L;
>>>>>>
>>>>>> -    @SuppressWarnings("unchecked")
>>>>>>  public final int doWikiStartTag()
>>>>>>      throws IOException
>>>>>>  {
>>>>>> -        Collection<SearchResult> list =
>>>>>> (Collection< 
>>>>>> SearchResult>)pageContext.getAttribute( "searchresults",
>>>>>> -
>>>>>> PageContext.REQUEST_SCOPE );
>>>>>> -
>>>>>> -        if( list != null )
>>>>>> +        if ( m_wikiActionBean != null && m_wikiActionBean  
>>>>>> instanceof
>>>>>> SearchActionBean )
>>>>>>      {
>>>>>> -            return EVAL_BODY_INCLUDE;
>>>>>> +            boolean emptyQuery =
>>>>>> ((SearchActionBean)m_wikiActionBean).getQuery() == null;
>>>>>> +            if ( !emptyQuery )
>>>>>> +            {
>>>>>> +                return EVAL_BODY_INCLUDE;
>>>>>> +            }
>>>>>>      }
>>>>>>
>>>>>>      String message = (String)pageContext.getAttribute( "err",
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>
>

Re: svn commit: r782495 - in /incubator/jspwiki/trunk/src: WebContent/ WebContent/scripts/ WebContent/templates/default/ java/org/apache/wiki/ java/org/apache/wiki/action/ java/org/apache/wiki/tags/

Posted by Janne Jalkanen <ja...@ecyrd.com>.
We compress the files anyway, so it could be done in the same ant  
task. The unfortunate side-effect would be that if the logical layout  
breaks from the deployment layout, it becomes difficult to deploy  
JSPWiki directly from inside Eclipse. Which would be odd considering  
all the trouble we went through enabling that functionality.

So concatenation might actually make development more difficult,  
rather than easier.

/Janne

On 9 Jun 2009, at 02:59, Andrew Jaquith wrote:

> There is a bigger issue here, too:
>
> I find ithard to comprehend how the JS code is organized. One  
> suggestion I was going to make was that we chop the js-common file  
> into smaller files for each logical group of funtionality (e.g.  
> search.js), then concatenate it all together at build time  
> (jspwiki.js). Thanks to Ant, this would be pretty easy, and would  
> make the JS easier to understand and maintain.
>
> +1 for Janne's idea, also. The function signature would need an  
> action URL, event name, array of parameters and a callback funtion.  
> Pretty much just like Janne's example. :)
>
> Andrew
>
>
> On Jun 8, 2009, at 15:53, Janne Jalkanen <ja...@ecyrd.com>  
> wrote:
>
>>
>> Reminds me - the JS code used to call Ajax routines is disgustingly  
>> loathsome and makes my eyes bleed and my stomach retch.  Can we  
>> upgrade to a newer Mootools lib (1.2.2, I think) and switch to  
>> Request.JSON and create a JSONFactory or an extension for creating  
>> our AJAX requests?
>>
>> Something like wiki.json( "Search", "ajaxSearch", { param1 :  
>> value1, ... }, callback(resultobj,resulttext) ); would be nice.  
>> This would construct the URL to SearchActionBean, method  
>> ajaxSearch, with the given params.
>>
>> /Janne
>>
>> On 8 Jun 2009, at 21:52, Andrew Jaquith wrote:
>>
>>> It will fix this one -- but only after we've hooked it up to the
>>> client JavaScript. Should not take long.
>>>
>>> On Mon, Jun 8, 2009 at 2:44 PM, Harry  
>>> Metske<ha...@gmail.com> wrote:
>>>> Andrew,
>>>>
>>>> should this patch have fixed
>>>> https://issues.apache.org/jira/browse/JSPWIKI-510 (only for 3.0  
>>>> of course) ?
>>>>
>>>> Harry
>>>>
>>>> 2009/6/8 <aj...@apache.org>
>>>>
>>>>> Author: ajaquith
>>>>> Date: Mon Jun  8 01:37:33 2009
>>>>> New Revision: 782495
>>>>>
>>>>> URL: http://svn.apache.org/viewvc?rev=782495&view=rev
>>>>> Log:
>>>>> Search.jsp migrated to Stripes. SearchActionBean now provides  
>>>>> searching
>>>>> logic, including an ajaxSearch() method that filters results  
>>>>> correctly (this
>>>>> is not hooked up to the client JavaScript yet, but it should be
>>>>> straightforward to do). Still some i18n cleanup to do.
>>>>>
>>>>> Modified:
>>>>>  incubator/jspwiki/trunk/src/WebContent/Search.jsp
>>>>>  incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-common.js
>>>>>  incubator/jspwiki/trunk/src/WebContent/templates/default/ 
>>>>> FindContent.jsp
>>>>>  incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiContext.java
>>>>>
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/action/ 
>>>>> SearchActionBean.java
>>>>>
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>> IfNoSearchResultsTag.java
>>>>>
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>> SearchResultIteratorTag.java
>>>>>
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>> SearchResultsSizeTag.java
>>>>>
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>> SearchResultsTag.java
>>>>>
>>>>> Modified: incubator/jspwiki/trunk/src/WebContent/Search.jsp
>>>>> URL:
>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/WebContent/Search.jsp?rev=782495&r1=782494&r2=782495&view=diff
>>>>>
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> ==================================================================
>>>>> --- incubator/jspwiki/trunk/src/WebContent/Search.jsp (original)
>>>>> +++ incubator/jspwiki/trunk/src/WebContent/Search.jsp Mon Jun  8  
>>>>> 01:37:33
>>>>> 2009
>>>>> @@ -18,108 +18,12 @@
>>>>>   specific language governing permissions and limitations
>>>>>   under the License.
>>>>> --%>
>>>>> -<%@ page import="org.apache.wiki.log.Logger" %>
>>>>> -<%@ page import="org.apache.wiki.log.LoggerFactory" %>
>>>>> -<%@ page import="org.apache.wiki.*" %>
>>>>> -<%@ page import="org.apache.wiki.auth.*" %>
>>>>> -<%@ page import="org.apache.wiki.auth.permissions.*" %>
>>>>> -<%@ page import="java.util.*" %>
>>>>> +<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld"  
>>>>> prefix="s" %>
>>>>> <%@ page errorPage="/Error.jsp" %>
>>>>> -<%@ page import="org.apache.wiki.search.*" %>
>>>>> -<%@ taglib uri="http://jakarta.apache.org/jspwiki.tld"  
>>>>> prefix="wiki" %>
>>>>> -<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld"
>>>>> prefix="stripes" %>
>>>>> -<%@ page import="org.apache.wiki.util.TextUtil" %>
>>>>> -<%@ page import="org.apache.wiki.api.WikiPage" %>
>>>>> -<stripes:useActionBean  
>>>>> beanclass="org.apache.wiki.action.SearchActionBean"
>>>>> event="find" id="wikiActionBean" />
>>>>> +<s:useActionBean  
>>>>> beanclass="org.apache.wiki.action.SearchActionBean"
>>>>> event="search" executeResolution="true" id="wikiActionBean" />
>>>>> +<s:layout-render name="${templates['DefaultLayout.jsp']}">
>>>>> +  <s:layout-component name="content">
>>>>> +      <jsp:include page="${templates['FindContent.jsp']}" />
>>>>> +  </s:layout-component>
>>>>> +</s:layout-render>
>>>>>
>>>>> -<%!
>>>>> -    Logger log = LoggerFactory.getLogger("JSPWikiSearch");
>>>>> -%>
>>>>> -
>>>>> -<%
>>>>> -    WikiEngine wiki =  
>>>>> WikiEngine.getInstance( getServletConfig() );
>>>>> -    // Create wiki context and check for authorization
>>>>> -    WikiContext wikiContext = wiki.createContext( request,
>>>>> WikiContext.FIND );
>>>>> -    String pagereq = wikiContext.getPage().getName();
>>>>> -
>>>>> -    // Get the search results
>>>>> -    Collection list = null;
>>>>> -    String query = request.getParameter( "query");
>>>>> -    String go    = request.getParameter("go");
>>>>> -
>>>>> -    if( query != null )
>>>>> -    {
>>>>> -        log.info("Searching for string "+query);
>>>>> -
>>>>> -        try
>>>>> -        {
>>>>> -            list = wiki.findPages( query );
>>>>> -
>>>>> -            //
>>>>> -            //  Filter down to only those that we actually have a
>>>>> permission to view
>>>>> -            //
>>>>> -            AuthorizationManager mgr =  
>>>>> wiki.getAuthorizationManager();
>>>>> -
>>>>> -            ArrayList filteredList = new ArrayList();
>>>>> -
>>>>> -            for( Iterator i = list.iterator(); i.hasNext(); )
>>>>> -            {
>>>>> -                SearchResult r = (SearchResult)i.next();
>>>>> -
>>>>> -                WikiPage p = r.getPage();
>>>>> -
>>>>> -                PagePermission pp = new PagePermission( p,
>>>>> PagePermission.VIEW_ACTION );
>>>>> -
>>>>> -                try
>>>>> -                {
>>>>> -                     
>>>>> if( mgr.checkPermission( wikiContext.getWikiSession(),
>>>>> pp ) )
>>>>> -                    {
>>>>> -                        filteredList.add( r );
>>>>> -                    }
>>>>> -                }
>>>>> -                catch( Exception e ) { log.error( "Searching  
>>>>> for page "+p,
>>>>> e ); }
>>>>> -            }
>>>>> -
>>>>> -            pageContext.setAttribute( "searchresults",
>>>>> -                                      filteredList,
>>>>> -                                       
>>>>> PageContext.REQUEST_SCOPE );
>>>>> -        }
>>>>> -        catch( Exception e )
>>>>> -        {
>>>>> -             
>>>>> wikiContext.getWikiSession().addMessage( e.getMessage() );
>>>>> -        }
>>>>> -
>>>>> -        query = TextUtil.replaceEntities( query );
>>>>> -
>>>>> -        pageContext.setAttribute( "query",
>>>>> -                                  query,
>>>>> -                                  PageContext.REQUEST_SCOPE );
>>>>> -
>>>>> -        //
>>>>> -        //  Did the user click on "go"?
>>>>> -        //
>>>>> -        if( go != null )
>>>>> -        {
>>>>> -            if( list != null && list.size() > 0 )
>>>>> -            {
>>>>> -                SearchResult sr = (SearchResult)  
>>>>> list.iterator().next();
>>>>> -
>>>>> -                WikiPage wikiPage = sr.getPage();
>>>>> -
>>>>> -                String url =  
>>>>> wikiContext.getViewURL( wikiPage.getName() );
>>>>> -
>>>>> -                response.sendRedirect( url );
>>>>> -
>>>>> -                return;
>>>>> -            }
>>>>> -        }
>>>>> -    }
>>>>> -
>>>>> -    // Set the content type and include the response content
>>>>> -    response.setContentType("text/html;
>>>>> charset="+wiki.getContentEncoding() );
>>>>> -    String contentPage =  
>>>>> wiki.getTemplateManager().findJSP( pageContext,
>>>>> -
>>>>> wikiContext.getTemplate(),
>>>>> -
>>>>> "ViewTemplate.jsp" );
>>>>> -%><wiki:Include page="<%=contentPage%>" /><%
>>>>> -    log.debug("SEARCH COMPLETE");
>>>>> -%>
>>>>>
>>>>> Modified: incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki- 
>>>>> common.js
>>>>> URL:
>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-common.js?rev=782495&r1=782494&r2=782495&view=diff
>>>>>
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> ==================================================================
>>>>> --- incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki- 
>>>>> common.js
>>>>> (original)
>>>>> +++ incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki- 
>>>>> common.js Mon
>>>>> Jun  8 01:37:33 2009
>>>>> @@ -931,9 +931,9 @@
>>>>>                      if (option.value == match) option.selected  
>>>>> = true;
>>>>>              });
>>>>>
>>>>> -               new Ajax(Wiki.TemplateUrl+'AJAXSearch.jsp', {
>>>>> -                       postBody: $ 
>>>>> ('searchform2').toQueryString(),
>>>>> -                       update: 'searchResult2',
>>>>> +               new Ajax(Wiki.BasePath+'Search.action', {
>>>>> +                       postBody:
>>>>> "ajaxSearch=&"+$('searchform2').toQueryString(),
>>>>> +                       update: 'searchResult2',
>>>>>                      method: 'post',
>>>>>                      onComplete: function() {
>>>>>                              $('spin').hide();
>>>>>
>>>>> Modified:
>>>>> incubator/jspwiki/trunk/src/WebContent/templates/default/ 
>>>>> FindContent.jsp
>>>>> URL:
>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/WebContent/templates/default/FindContent.jsp?rev=782495&r1=782494&r2=782495&view=diff
>>>>>
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> ==================================================================
>>>>> ---
>>>>> incubator/jspwiki/trunk/src/WebContent/templates/default/ 
>>>>> FindContent.jsp
>>>>> (original)
>>>>> +++
>>>>> incubator/jspwiki/trunk/src/WebContent/templates/default/ 
>>>>> FindContent.jsp Mon
>>>>> Jun  8 01:37:33 2009
>>>>> @@ -27,24 +27,18 @@
>>>>> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
>>>>> <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
>>>>> <%@ page import="javax.servlet.jsp.jstl.fmt.*" %>
>>>>> -<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld"
>>>>> prefix="stripes" %>
>>>>> +<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld"  
>>>>> prefix="s" %>
>>>>>
>>>>> <wiki:TabbedSection>
>>>>> <wiki:Tab id="findcontent" titleKey="find.tab" accesskey="s">
>>>>>
>>>>> -<form action="<wiki:Link format='url' jsp='Search.jsp'/>"
>>>>> -       class="wikiform"
>>>>> -          id="searchform2"
>>>>> -         accept-charset="<wiki:ContentEncoding/>">
>>>>> -
>>>>> +<s:form beanclass="org.apache.wiki.action.SearchActionBean"
>>>>> class="wikiform"
>>>>> +    id="searchform2" acceptcharset="UTF-8">
>>>>> +
>>>>> <h4><fmt:message key="find.input" /></h4>
>>>>> <p>
>>>>> -    <input type="text"
>>>>> -           name="query" id="query2"
>>>>> -          value="<c:out value='${query}'/>"
>>>>> -           size="32" />
>>>>> -
>>>>> -    <input type="checkbox" name="details" id="details" <c:if
>>>>> test='${param.details == "on"}'>checked='checked'</c:if> />
>>>>> +    <s:text name="query" id="query2" size="32" />
>>>>> +    <s:checkbox name="details" id="details" />
>>>>>   <fmt:message key="find.details" />
>>>>>
>>>>>   <select name="scope" id="scope">
>>>>> @@ -55,16 +49,83 @@
>>>>>     <option value="attachment:" <c:if test='${param.scope eq
>>>>> "attachment:"}'>selected="selected"</c:if> ><fmt:message
>>>>> key='find.scope.attach' /></option>
>>>>>   </select>
>>>>>
>>>>> -       <input type="submit" name="ok" id="ok" value="<fmt:message
>>>>> key="find.submit.find" />" />
>>>>> -       <input type="submit" name="go" id="go" value="<fmt:message
>>>>> key="find.submit.go" />" />
>>>>> -    <input type="hidden" name="start" id="start" value="0" />
>>>>> -    <input type="hidden" name="maxitems" id="maxitems"  
>>>>> value="20" />
>>>>> +    <s:submit name="search" id="ok" value="<fmt:message
>>>>> key='find.submit.find' />" />
>>>>> +    <s:submit name="go" id="go" value="<fmt:message  
>>>>> key='find.submit.go'
>>>>> />" />
>>>>> +    <s:hidden name="start" id="start" value="0" />
>>>>> +    <s:hidden name="maxItems" id="maxitems" value="20" />
>>>>>
>>>>>   <span id="spin" class="spin"
>>>>> style="position:absolute;display:none;"></span>
>>>>> </p>
>>>>> -</form>
>>>>> +</s:form>
>>>>> +
>>>>> +<div id="searchResult2">
>>>>> +  <wiki:SearchResults>
>>>>> +
>>>>> +    <h4><fmt:message key="find.heading.results"><fmt:param><c:out
>>>>> value="${wikiActionBean.query}" /></fmt:param></fmt:message></h4>
>>>>> +    <p>
>>>>> +      <fmt:message key="find.externalsearch" />
>>>>> +      <a class="external" href="http://www.google.com/search? 
>>>>> q=<c:out
>>>>> value='${wikiActionBean.query}' />" title="Google Search '<c:out
>>>>> value='${wikiActionBean.query}' />'" target="_blank">Google</ 
>>>>> a><img
>>>>> class="outlink" src="images/out.png" alt="" />
>>>>> +      |
>>>>> +      <a class="external" href="
>>>>> http://en.wikipedia.org/wiki/Special:Search?search=<c:out
>>>>> value='${wikiActionBean.query}' />" title="Wikipedia Search  
>>>>> '<c:out
>>>>> value='${wikiActionBean.query}' />'" target="_blank">Wikipedia</ 
>>>>> a><img
>>>>> class="outlink" src="images/out.png" alt="" />
>>>>> +    </p>
>>>>> +
>>>>> +    <wiki:SetPagination start="${wikiActionBean.start}"
>>>>> total="${wikiActionBean.resultsCount}" pagesize="20" maxlinks="9"
>>>>> fmtkey="info.pagination" onclick="$('start').value=%s;
>>>>> SearchBox.runfullsearch();" />
>>>>> +
>>>>> +    <div class="graphBars">
>>>>> +      <div class="zebra-table">
>>>>> +        <table class="wikitable">
>>>>> +
>>>>> +          <tr>
>>>>> +             <th align="left"><fmt:message  
>>>>> key="find.results.page" /></th>
>>>>> +             <th align="left"><fmt:message  
>>>>> key="find.results.score"
>>>>> /></th>
>>>>> +          </tr>
>>>>> +
>>>>> +          <wiki:SearchResultIterator id="searchref"
>>>>> start="${wikiActionBean.start}" maxItems="$ 
>>>>> {wikiActionBean.maxItems}">
>>>>> +          <tr>
>>>>> +            <td><wiki:LinkTo><wiki:PageName/></wiki:LinkTo></td>
>>>>> +            <td><span class="gBar"><%= searchref.getScore() %></ 
>>>>> span></td>
>>>>> +          </tr>
>>>>> +
>>>>> +          <c:if test="${wikiActionBean.details == 'true'}">
>>>>> +  <%
>>>>> +            String[] contexts = searchref.getContexts();
>>>>> +            if( (contexts != null) && (contexts.length > 0) )
>>>>> +            {
>>>>> +  %>
>>>>> +          <tr class="odd">
>>>>> +            <td colspan="2">
>>>>> +              <div class="fragment">
>>>>> +  <%
>>>>> +              for (int i = 0; i < contexts.length; i++)
>>>>> +              {
>>>>> +  %>
>>>>> +                <%= (i > 0 ) ? "<span  
>>>>> class='fragment_ellipsis'> ...
>>>>> </span>" : ""  %>
>>>>> +                <%= contexts[i]  %>
>>>>> +  <%
>>>>> +              }
>>>>> +  %>
>>>>> +               </div>
>>>>> +             </td>
>>>>> +           </tr>
>>>>> +  <%
>>>>> +            }
>>>>> +  %>
>>>>> +          </c:if><%-- details --%>
>>>>> +        </wiki:SearchResultIterator>
>>>>> +
>>>>> +        <wiki:IfNoSearchResults>
>>>>> +          <tr>
>>>>> +            <td class="nosearchresult" colspan="2"><fmt:message
>>>>> key="find.noresults" /></td>
>>>>> +          </tr>
>>>>> +        </wiki:IfNoSearchResults>
>>>>> +
>>>>> +        </table>
>>>>> +      </div>
>>>>> +    </div>
>>>>> +    ${pagination}
>>>>>
>>>>> -<div id="searchResult2"><wiki:Include page="AJAXSearch.jsp" /></ 
>>>>> div>
>>>>> +  </wiki:SearchResults>
>>>>> +</div>
>>>>>
>>>>> </wiki:Tab>
>>>>>
>>>>>
>>>>> Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/ 
>>>>> WikiContext.java
>>>>> URL:
>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiContext.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>>
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> ==================================================================
>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/ 
>>>>> WikiContext.java
>>>>> (original)
>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/ 
>>>>> WikiContext.java Mon
>>>>> Jun  8 01:37:33 2009
>>>>> @@ -103,7 +103,7 @@
>>>>>   public static final String    COMMENT  =  
>>>>> HandlerInfo.getHandlerInfo(
>>>>> EditActionBean.class, "comment" ).getRequestContext();
>>>>>
>>>>>   /** User is searching for content. */
>>>>> -    public static final String    FIND     =  
>>>>> HandlerInfo.getHandlerInfo(
>>>>> SearchActionBean.class, "find" ).getRequestContext();
>>>>> +    public static final String    FIND     =  
>>>>> HandlerInfo.getHandlerInfo(
>>>>> SearchActionBean.class, "search" ).getRequestContext();
>>>>>
>>>>>   /** User wishes to create a new group */
>>>>>   public static final String    CREATE_GROUP =
>>>>> HandlerInfo.getHandlerInfo( GroupActionBean.class, "create"
>>>>> ).getRequestContext();
>>>>>
>>>>> Modified:
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/action/ 
>>>>> SearchActionBean.java
>>>>> URL:
>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/action/SearchActionBean.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>>
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> ==================================================================
>>>>> ---
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/action/ 
>>>>> SearchActionBean.java
>>>>> (original)
>>>>> +++
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/action/ 
>>>>> SearchActionBean.java
>>>>> Mon Jun  8 01:37:33 2009
>>>>> @@ -21,18 +21,191 @@
>>>>>
>>>>> package org.apache.wiki.action;
>>>>>
>>>>> -import org.apache.wiki.ui.stripes.WikiRequestContext;
>>>>> +import java.util.ArrayList;
>>>>> +import java.util.Collection;
>>>>> +import java.util.Collections;
>>>>> +import java.util.List;
>>>>>
>>>>> import net.sourceforge.stripes.action.*;
>>>>> +import net.sourceforge.stripes.ajax.JavaScriptResolution;
>>>>> +
>>>>> +import org.apache.wiki.WikiEngine;
>>>>> +import org.apache.wiki.api.WikiPage;
>>>>> +import org.apache.wiki.auth.AuthorizationManager;
>>>>> +import org.apache.wiki.auth.permissions.PagePermission;
>>>>> +import org.apache.wiki.log.Logger;
>>>>> +import org.apache.wiki.log.LoggerFactory;
>>>>> +import org.apache.wiki.search.SearchResult;
>>>>> +import org.apache.wiki.ui.stripes.WikiRequestContext;
>>>>>
>>>>> +/**
>>>>> + * Searches the WikiPage collection for a given wiki.
>>>>> + */
>>>>> @UrlBinding( "/Search.jsp" )
>>>>> public class SearchActionBean extends AbstractActionBean
>>>>> {
>>>>> +    private Logger log =  
>>>>> LoggerFactory.getLogger("JSPWikiSearch");
>>>>> +
>>>>> +    public static final Collection<SearchResult> NO_RESULTS =
>>>>> Collections.emptyList();
>>>>> +
>>>>> +    private Collection<SearchResult> m_results = NO_RESULTS;
>>>>> +
>>>>> +    private String m_query = null;
>>>>> +
>>>>> +    private int m_maxItems = 20;
>>>>> +
>>>>> +    private int m_start = 0;
>>>>> +
>>>>> +    private boolean m_details = false;
>>>>> +
>>>>> +    public boolean getDetails()
>>>>> +    {
>>>>> +        return m_details;
>>>>> +    }
>>>>> +
>>>>> +    /**
>>>>> +     * Sets the search results so that details for each result  
>>>>> are
>>>>> displayed.
>>>>> +     * @param details whether details should be displayed
>>>>> +     */
>>>>> +    public void setDetails( boolean details )
>>>>> +    {
>>>>> +        m_details = details;
>>>>> +    }
>>>>> +
>>>>> +    public int getMaxItems()
>>>>> +    {
>>>>> +        return m_maxItems;
>>>>> +    }
>>>>> +
>>>>> +    public void setMaxItems( int maxItems )
>>>>> +    {
>>>>> +        m_maxItems = maxItems;
>>>>> +    }
>>>>> +
>>>>> +    public int getStart()
>>>>> +    {
>>>>> +        return m_start;
>>>>> +    }
>>>>> +
>>>>> +    public void setStart( int start )
>>>>> +    {
>>>>> +        m_start = start;
>>>>> +    }
>>>>> +
>>>>> +    /**
>>>>> +     * Returns the query string for the search.
>>>>> +     *
>>>>> +     * @return the query string
>>>>> +     */
>>>>> +    public String getQuery()
>>>>> +    {
>>>>> +        return m_query;
>>>>> +    }
>>>>> +
>>>>> +    /**
>>>>> +     * Returns the results of the search.
>>>>> +     *
>>>>> +     * @return the results
>>>>> +     */
>>>>> +    public Collection<SearchResult> getResults()
>>>>> +    {
>>>>> +        return m_results;
>>>>> +    }
>>>>> +
>>>>> +    /**
>>>>> +     * Returns the number of items returned by the current  
>>>>> search.
>>>>> +     * @return the number of items
>>>>> +     */
>>>>> +    public int getResultsCount()
>>>>> +    {
>>>>> +        return m_results.size();
>>>>> +    }
>>>>> +
>>>>> +    /**
>>>>> +     * Performs a search and returns the results as a list. For  
>>>>> a given
>>>>> WikiPage to
>>>>> +     * be included in the results, the user must have  
>>>>> permission to view
>>>>> it.
>>>>> +     * If the underlying providers encounter an abnormal  
>>>>> IOException or
>>>>> other error,
>>>>> +     * it will be added to the ActionBeanContext's validation  
>>>>> messages
>>>>> collection.
>>>>> +     * @param query the query
>>>>> +     * @return the results
>>>>> +     */
>>>>> +    private List<SearchResult> doSearch( String query )
>>>>> +    {
>>>>> +        log.info("Searching with query '"+ query + "'.");
>>>>> +        WikiEngine engine = getContext().getEngine();
>>>>> +        AuthorizationManager mgr =  
>>>>> engine.getAuthorizationManager();
>>>>> +
>>>>> +        //
>>>>> +        //  Filter down to only those that we actually have a  
>>>>> permission
>>>>> to view
>>>>> +        //
>>>>> +        List<SearchResult> filteredResults = new
>>>>> ArrayList<SearchResult>();
>>>>> +        try
>>>>> +        {
>>>>> +            List<SearchResult> results =  
>>>>> engine.findPages( query );
>>>>> +            for( SearchResult result : results )
>>>>> +            {
>>>>> +                WikiPage page = result.getPage();
>>>>> +                PagePermission permission = new  
>>>>> PagePermission( page,
>>>>> PagePermission.VIEW_ACTION );
>>>>> +                try
>>>>> +                {
>>>>> +                    if( mgr.checkPermission(
>>>>> getContext().getWikiSession(), permission ) )
>>>>> +                    {
>>>>> +                        filteredResults.add( result );
>>>>> +                    }
>>>>> +                }
>>>>> +                catch( Exception e ) { log.error( "Searching  
>>>>> for page " +
>>>>> page, e ); }
>>>>> +            }
>>>>> +        }
>>>>> +        catch( Exception e )
>>>>> +        {
>>>>> +            log.debug( "Could not search using query '" + query  
>>>>> + "'.", e
>>>>> );
>>>>> +            Message message = new  
>>>>> SimpleMessage( e.getMessage() );
>>>>> +            getContext().getMessages().add( message );
>>>>> +            e.printStackTrace();
>>>>> +        }
>>>>> +        return filteredResults;
>>>>> +    }
>>>>> +
>>>>> +    /**
>>>>> +     * Sets the query string for the search.
>>>>> +     *
>>>>> +     * @param query the query string
>>>>> +     */
>>>>> +    public void setQuery( String query )
>>>>> +    {
>>>>> +        m_query = query;
>>>>> +    }
>>>>> +
>>>>> +    /**
>>>>> +     * Searches the wiki using the query string set for this
>>>>> +     * ActionBean. Search results are made available to callers  
>>>>> via the
>>>>> +     * {@link #getResults()} method (and EL expression
>>>>> +     * <code>$wikiActionBean.results</code>).
>>>>> +     *
>>>>> +     * @return always returns a {@link ForwardResolution} to
>>>>> +     *         <code>/Search.jsp</code>.
>>>>> +     */
>>>>>   @DefaultHandler
>>>>> -    @HandlesEvent( "find" )
>>>>> +    @HandlesEvent( "search" )
>>>>>   @WikiRequestContext( "find" )
>>>>> -    public Resolution view()
>>>>> +    public Resolution search()
>>>>>   {
>>>>> +        m_results = m_query == null ? NO_RESULTS :  
>>>>> doSearch( m_query );
>>>>>       return new ForwardResolution( "/Search.jsp" );
>>>>>   }
>>>>> +
>>>>> +    /**
>>>>> +     * Using AJAX, searches a specified wiki space using the  
>>>>> query string
>>>>> set for this
>>>>> +     * ActionBean. Results are streamed back to the client as  
>>>>> an array of
>>>>> JSON-encoded
>>>>> +     * SearchResult objects.
>>>>> +     *
>>>>> +     * @return always returns a {@link JavaScriptResolution}  
>>>>> containing
>>>>> the
>>>>> +     * results; this may be a zero-length array
>>>>> +     */
>>>>> +    @HandlesEvent( "ajaxSearch" )
>>>>> +    public Resolution ajaxSearch()
>>>>> +    {
>>>>> +        m_results = m_query == null ? NO_RESULTS :  
>>>>> doSearch( m_query );
>>>>> +        return new JavaScriptResolution( m_results );
>>>>> +    }
>>>>> }
>>>>>
>>>>> Modified:
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>> IfNoSearchResultsTag.java
>>>>> URL:
>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IfNoSearchResultsTag.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>>
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> ==================================================================
>>>>> ---
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>> IfNoSearchResultsTag.java
>>>>> (original)
>>>>> +++
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>> IfNoSearchResultsTag.java
>>>>> Mon Jun  8 01:37:33 2009
>>>>> @@ -22,8 +22,8 @@
>>>>>
>>>>> import java.io.IOException;
>>>>> import java.util.Collection;
>>>>> -import javax.servlet.jsp.PageContext;
>>>>>
>>>>> +import org.apache.wiki.action.SearchActionBean;
>>>>> import org.apache.wiki.search.SearchResult;
>>>>>
>>>>> /**
>>>>> @@ -36,17 +36,18 @@
>>>>> {
>>>>>   private static final long serialVersionUID = 0L;
>>>>>
>>>>> -    @SuppressWarnings("unchecked")
>>>>>   public final int doWikiStartTag()
>>>>>       throws IOException
>>>>>   {
>>>>> -        Collection<SearchResult> list =
>>>>> (Collection 
>>>>> <SearchResult>)pageContext.getAttribute( "searchresults",
>>>>> -
>>>>> PageContext.REQUEST_SCOPE );
>>>>> -        if( list == null || list.size() == 0 )
>>>>> -        {
>>>>> -            return EVAL_BODY_INCLUDE;
>>>>> +        if ( m_wikiActionBean != null && m_wikiActionBean  
>>>>> instanceof
>>>>> SearchActionBean )
>>>>> +        {
>>>>> +            boolean emptyQuery =
>>>>> ((SearchActionBean)m_wikiActionBean).getQuery() == null;
>>>>> +            Collection<SearchResult> results =
>>>>> ((SearchActionBean)m_wikiActionBean).getResults();
>>>>> +            if ( emptyQuery || results.size() > 0 )
>>>>> +            {
>>>>> +                return SKIP_BODY;
>>>>> +            }
>>>>>       }
>>>>> -
>>>>> -        return SKIP_BODY;
>>>>> +        return EVAL_BODY_INCLUDE;
>>>>>   }
>>>>> }
>>>>>
>>>>> Modified:
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>> SearchResultIteratorTag.java
>>>>> URL:
>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultIteratorTag.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>>
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> ==================================================================
>>>>> ---
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>> SearchResultIteratorTag.java
>>>>> (original)
>>>>> +++
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>> SearchResultIteratorTag.java
>>>>> Mon Jun  8 01:37:33 2009
>>>>> @@ -20,12 +20,12 @@
>>>>> */
>>>>> package org.apache.wiki.tags;
>>>>>
>>>>> -import java.util.ArrayList;
>>>>> import java.util.Collection;
>>>>>
>>>>> -import javax.servlet.jsp.PageContext;
>>>>> -
>>>>> +import org.apache.wiki.action.SearchActionBean;
>>>>> +import org.apache.wiki.action.WikiActionBean;
>>>>> import org.apache.wiki.search.SearchResult;
>>>>> +import org.apache.wiki.ui.stripes.WikiInterceptor;
>>>>>
>>>>> /**
>>>>> * Iterator tag for the current search results, as identified by a
>>>>> @@ -36,19 +36,17 @@
>>>>>   private static final long serialVersionUID = 1L;
>>>>>
>>>>>   /**
>>>>> -     * \ Returns the list of SearchResults to iterate over.
>>>>> +     * Returns the list of SearchResults to iterate over.
>>>>>    */
>>>>>   @Override
>>>>> -    @SuppressWarnings( "unchecked" )
>>>>>   protected Collection<SearchResult> initItems()
>>>>>   {
>>>>> -        Collection<SearchResult> results =  
>>>>> (Collection<SearchResult>)
>>>>> pageContext.getAttribute( "searchresults",
>>>>> -
>>>>>                    PageContext.REQUEST_SCOPE );
>>>>> -        if( results == null )
>>>>> +        WikiActionBean actionBean =  
>>>>> WikiInterceptor.findActionBean(
>>>>> pageContext );
>>>>> +        if ( actionBean != null && actionBean instanceof  
>>>>> SearchActionBean
>>>>> )
>>>>>       {
>>>>> -            return new ArrayList<SearchResult>();
>>>>> +            return ((SearchActionBean)actionBean).getResults();
>>>>>       }
>>>>> -        return results;
>>>>> +        return SearchActionBean.NO_RESULTS;
>>>>>   }
>>>>>
>>>>>   /**
>>>>>
>>>>> Modified:
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>> SearchResultsSizeTag.java
>>>>> URL:
>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsSizeTag.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>>
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> ==================================================================
>>>>> ---
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>> SearchResultsSizeTag.java
>>>>> (original)
>>>>> +++
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>> SearchResultsSizeTag.java
>>>>> Mon Jun  8 01:37:33 2009
>>>>> @@ -22,8 +22,8 @@
>>>>>
>>>>> import java.io.IOException;
>>>>> import java.util.Collection;
>>>>> -import javax.servlet.jsp.PageContext;
>>>>>
>>>>> +import org.apache.wiki.action.SearchActionBean;
>>>>> import org.apache.wiki.search.SearchResult;
>>>>>
>>>>> /**
>>>>> @@ -37,17 +37,14 @@
>>>>> {
>>>>>   private static final long serialVersionUID = 0L;
>>>>>
>>>>> -    @SuppressWarnings("unchecked")
>>>>>   public final int doWikiStartTag()
>>>>>       throws IOException
>>>>>   {
>>>>> -        Collection<SearchResult> list =
>>>>> (Collection 
>>>>> <SearchResult>)pageContext.getAttribute( "searchresults",
>>>>> -
>>>>> PageContext.REQUEST_SCOPE );
>>>>> -        if( list != null )
>>>>> +        if ( m_wikiActionBean != null && m_wikiActionBean  
>>>>> instanceof
>>>>> SearchActionBean )
>>>>>       {
>>>>> -            pageContext.getOut().print( list.size() );
>>>>> +            Collection<SearchResult> results =
>>>>> ((SearchActionBean)m_wikiActionBean).getResults();
>>>>> +            pageContext.getOut().print( results.size() );
>>>>>       }
>>>>> -
>>>>>       return SKIP_BODY;
>>>>>   }
>>>>> }
>>>>>
>>>>> Modified:
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>> SearchResultsTag.java
>>>>> URL:
>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsTag.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>>
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> ==================================================================
>>>>> ---
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>> SearchResultsTag.java
>>>>> (original)
>>>>> +++
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>> SearchResultsTag.java
>>>>> Mon Jun  8 01:37:33 2009
>>>>> @@ -21,10 +21,10 @@
>>>>> package org.apache.wiki.tags;
>>>>>
>>>>> import java.io.IOException;
>>>>> -import java.util.Collection;
>>>>> +
>>>>> import javax.servlet.jsp.PageContext;
>>>>>
>>>>> -import org.apache.wiki.search.SearchResult;
>>>>> +import org.apache.wiki.action.SearchActionBean;
>>>>>
>>>>> /**
>>>>> *  Includes the body content, if there are any search results.
>>>>> @@ -36,16 +36,16 @@
>>>>> {
>>>>>   private static final long serialVersionUID = 0L;
>>>>>
>>>>> -    @SuppressWarnings("unchecked")
>>>>>   public final int doWikiStartTag()
>>>>>       throws IOException
>>>>>   {
>>>>> -        Collection<SearchResult> list =
>>>>> (Collection 
>>>>> <SearchResult>)pageContext.getAttribute( "searchresults",
>>>>> -
>>>>> PageContext.REQUEST_SCOPE );
>>>>> -
>>>>> -        if( list != null )
>>>>> +        if ( m_wikiActionBean != null && m_wikiActionBean  
>>>>> instanceof
>>>>> SearchActionBean )
>>>>>       {
>>>>> -            return EVAL_BODY_INCLUDE;
>>>>> +            boolean emptyQuery =
>>>>> ((SearchActionBean)m_wikiActionBean).getQuery() == null;
>>>>> +            if ( !emptyQuery )
>>>>> +            {
>>>>> +                return EVAL_BODY_INCLUDE;
>>>>> +            }
>>>>>       }
>>>>>
>>>>>       String message = (String)pageContext.getAttribute( "err",
>>>>>
>>>>>
>>>>>
>>>>
>>
>>
>>>>> /**
>>>>> *  Includes the body content, if there are any search results.
>>>>> @@ -36,16 +36,16 @@
>>>>> {
>>>>>   private static final long serialVersionUID = 0L;
>>>>>
>>>>> -    @SuppressWarnings("unchecked")
>>>>>   public final int doWikiStartTag()
>>>>>       throws IOException
>>>>>   {
>>>>> -        Collection<SearchResult> list =
>>>>> (Collection 
>>>>> <SearchResult>)pageContext.getAttribute( "searchresults",
>>>>> -
>>>>> PageContext.REQUEST_SCOPE );
>>>>> -
>>>>> -        if( list != null )
>>>>> +        if ( m_wikiActionBean != null && m_wikiActionBean  
>>>>> instanceof
>>>>> SearchActionBean )
>>>>>       {
>>>>> -            return EVAL_BODY_INCLUDE;
>>>>> +            boolean emptyQuery =
>>>>> ((SearchActionBean)m_wikiActionBean).getQuery() == null;
>>>>> +            if ( !emptyQuery )
>>>>> +            {
>>>>> +                return EVAL_BODY_INCLUDE;
>>>>> +            }
>>>>>       }
>>>>>
>>>>>       String message = (String)pageContext.getAttribute( "err",
>>>>>
>>>>>
>>>>>
>>>>
>>


Re: svn commit: r782495 - in /incubator/jspwiki/trunk/src: WebContent/ WebContent/scripts/ WebContent/templates/default/ java/org/apache/wiki/ java/org/apache/wiki/action/ java/org/apache/wiki/tags/

Posted by Andrew Jaquith <an...@gmail.com>.
There is a bigger issue here, too:

I find ithard to comprehend how the JS code is organized. One  
suggestion I was going to make was that we chop the js-common file  
into smaller files for each logical group of funtionality (e.g.  
search.js), then concatenate it all together at build time  
(jspwiki.js). Thanks to Ant, this would be pretty easy, and would make  
the JS easier to understand and maintain.

+1 for Janne's idea, also. The function signature would need an action  
URL, event name, array of parameters and a callback funtion. Pretty  
much just like Janne's example. :)

Andrew


On Jun 8, 2009, at 15:53, Janne Jalkanen <ja...@ecyrd.com>  
wrote:

>
> Reminds me - the JS code used to call Ajax routines is disgustingly  
> loathsome and makes my eyes bleed and my stomach retch.  Can we  
> upgrade to a newer Mootools lib (1.2.2, I think) and switch to  
> Request.JSON and create a JSONFactory or an extension for creating  
> our AJAX requests?
>
> Something like wiki.json( "Search", "ajaxSearch", { param1 :  
> value1, ... }, callback(resultobj,resulttext) ); would be nice. This  
> would construct the URL to SearchActionBean, method ajaxSearch, with  
> the given params.
>
> /Janne
>
> On 8 Jun 2009, at 21:52, Andrew Jaquith wrote:
>
>> It will fix this one -- but only after we've hooked it up to the
>> client JavaScript. Should not take long.
>>
>> On Mon, Jun 8, 2009 at 2:44 PM, Harry  
>> Metske<ha...@gmail.com> wrote:
>>> Andrew,
>>>
>>> should this patch have fixed
>>> https://issues.apache.org/jira/browse/JSPWIKI-510 (only for 3.0 of  
>>> course) ?
>>>
>>> Harry
>>>
>>> 2009/6/8 <aj...@apache.org>
>>>
>>>> Author: ajaquith
>>>> Date: Mon Jun  8 01:37:33 2009
>>>> New Revision: 782495
>>>>
>>>> URL: http://svn.apache.org/viewvc?rev=782495&view=rev
>>>> Log:
>>>> Search.jsp migrated to Stripes. SearchActionBean now provides  
>>>> searching
>>>> logic, including an ajaxSearch() method that filters results  
>>>> correctly (this
>>>> is not hooked up to the client JavaScript yet, but it should be
>>>> straightforward to do). Still some i18n cleanup to do.
>>>>
>>>> Modified:
>>>>   incubator/jspwiki/trunk/src/WebContent/Search.jsp
>>>>   incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-common.js
>>>>   incubator/jspwiki/trunk/src/WebContent/templates/default/ 
>>>> FindContent.jsp
>>>>   incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiContext.java
>>>>
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/action/ 
>>>> SearchActionBean.java
>>>>
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>> IfNoSearchResultsTag.java
>>>>
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>> SearchResultIteratorTag.java
>>>>
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>> SearchResultsSizeTag.java
>>>>
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>> SearchResultsTag.java
>>>>
>>>> Modified: incubator/jspwiki/trunk/src/WebContent/Search.jsp
>>>> URL:
>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/WebContent/Search.jsp?rev=782495&r1=782494&r2=782495&view=diff
>>>>
>>>> === 
>>>> === 
>>>> === 
>>>> === 
>>>> ==================================================================
>>>> --- incubator/jspwiki/trunk/src/WebContent/Search.jsp (original)
>>>> +++ incubator/jspwiki/trunk/src/WebContent/Search.jsp Mon Jun  8  
>>>> 01:37:33
>>>> 2009
>>>> @@ -18,108 +18,12 @@
>>>>    specific language governing permissions and limitations
>>>>    under the License.
>>>> --%>
>>>> -<%@ page import="org.apache.wiki.log.Logger" %>
>>>> -<%@ page import="org.apache.wiki.log.LoggerFactory" %>
>>>> -<%@ page import="org.apache.wiki.*" %>
>>>> -<%@ page import="org.apache.wiki.auth.*" %>
>>>> -<%@ page import="org.apache.wiki.auth.permissions.*" %>
>>>> -<%@ page import="java.util.*" %>
>>>> +<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld"  
>>>> prefix="s" %>
>>>> <%@ page errorPage="/Error.jsp" %>
>>>> -<%@ page import="org.apache.wiki.search.*" %>
>>>> -<%@ taglib uri="http://jakarta.apache.org/jspwiki.tld"  
>>>> prefix="wiki" %>
>>>> -<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld"
>>>> prefix="stripes" %>
>>>> -<%@ page import="org.apache.wiki.util.TextUtil" %>
>>>> -<%@ page import="org.apache.wiki.api.WikiPage" %>
>>>> -<stripes:useActionBean  
>>>> beanclass="org.apache.wiki.action.SearchActionBean"
>>>> event="find" id="wikiActionBean" />
>>>> +<s:useActionBean  
>>>> beanclass="org.apache.wiki.action.SearchActionBean"
>>>> event="search" executeResolution="true" id="wikiActionBean" />
>>>> +<s:layout-render name="${templates['DefaultLayout.jsp']}">
>>>> +  <s:layout-component name="content">
>>>> +      <jsp:include page="${templates['FindContent.jsp']}" />
>>>> +  </s:layout-component>
>>>> +</s:layout-render>
>>>>
>>>> -<%!
>>>> -    Logger log = LoggerFactory.getLogger("JSPWikiSearch");
>>>> -%>
>>>> -
>>>> -<%
>>>> -    WikiEngine wiki =  
>>>> WikiEngine.getInstance( getServletConfig() );
>>>> -    // Create wiki context and check for authorization
>>>> -    WikiContext wikiContext = wiki.createContext( request,
>>>> WikiContext.FIND );
>>>> -    String pagereq = wikiContext.getPage().getName();
>>>> -
>>>> -    // Get the search results
>>>> -    Collection list = null;
>>>> -    String query = request.getParameter( "query");
>>>> -    String go    = request.getParameter("go");
>>>> -
>>>> -    if( query != null )
>>>> -    {
>>>> -        log.info("Searching for string "+query);
>>>> -
>>>> -        try
>>>> -        {
>>>> -            list = wiki.findPages( query );
>>>> -
>>>> -            //
>>>> -            //  Filter down to only those that we actually have a
>>>> permission to view
>>>> -            //
>>>> -            AuthorizationManager mgr =  
>>>> wiki.getAuthorizationManager();
>>>> -
>>>> -            ArrayList filteredList = new ArrayList();
>>>> -
>>>> -            for( Iterator i = list.iterator(); i.hasNext(); )
>>>> -            {
>>>> -                SearchResult r = (SearchResult)i.next();
>>>> -
>>>> -                WikiPage p = r.getPage();
>>>> -
>>>> -                PagePermission pp = new PagePermission( p,
>>>> PagePermission.VIEW_ACTION );
>>>> -
>>>> -                try
>>>> -                {
>>>> -                     
>>>> if( mgr.checkPermission( wikiContext.getWikiSession(),
>>>> pp ) )
>>>> -                    {
>>>> -                        filteredList.add( r );
>>>> -                    }
>>>> -                }
>>>> -                catch( Exception e ) { log.error( "Searching for  
>>>> page "+p,
>>>> e ); }
>>>> -            }
>>>> -
>>>> -            pageContext.setAttribute( "searchresults",
>>>> -                                      filteredList,
>>>> -                                      PageContext.REQUEST_SCOPE );
>>>> -        }
>>>> -        catch( Exception e )
>>>> -        {
>>>> -             
>>>> wikiContext.getWikiSession().addMessage( e.getMessage() );
>>>> -        }
>>>> -
>>>> -        query = TextUtil.replaceEntities( query );
>>>> -
>>>> -        pageContext.setAttribute( "query",
>>>> -                                  query,
>>>> -                                  PageContext.REQUEST_SCOPE );
>>>> -
>>>> -        //
>>>> -        //  Did the user click on "go"?
>>>> -        //
>>>> -        if( go != null )
>>>> -        {
>>>> -            if( list != null && list.size() > 0 )
>>>> -            {
>>>> -                SearchResult sr = (SearchResult)  
>>>> list.iterator().next();
>>>> -
>>>> -                WikiPage wikiPage = sr.getPage();
>>>> -
>>>> -                String url =  
>>>> wikiContext.getViewURL( wikiPage.getName() );
>>>> -
>>>> -                response.sendRedirect( url );
>>>> -
>>>> -                return;
>>>> -            }
>>>> -        }
>>>> -    }
>>>> -
>>>> -    // Set the content type and include the response content
>>>> -    response.setContentType("text/html;
>>>> charset="+wiki.getContentEncoding() );
>>>> -    String contentPage =  
>>>> wiki.getTemplateManager().findJSP( pageContext,
>>>> -
>>>> wikiContext.getTemplate(),
>>>> -
>>>> "ViewTemplate.jsp" );
>>>> -%><wiki:Include page="<%=contentPage%>" /><%
>>>> -    log.debug("SEARCH COMPLETE");
>>>> -%>
>>>>
>>>> Modified: incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki- 
>>>> common.js
>>>> URL:
>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-common.js?rev=782495&r1=782494&r2=782495&view=diff
>>>>
>>>> === 
>>>> === 
>>>> === 
>>>> === 
>>>> ==================================================================
>>>> --- incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki- 
>>>> common.js
>>>> (original)
>>>> +++ incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki- 
>>>> common.js Mon
>>>> Jun  8 01:37:33 2009
>>>> @@ -931,9 +931,9 @@
>>>>                       if (option.value == match) option.selected  
>>>> = true;
>>>>               });
>>>>
>>>> -               new Ajax(Wiki.TemplateUrl+'AJAXSearch.jsp', {
>>>> -                       postBody: $('searchform2').toQueryString(),
>>>> -                       update: 'searchResult2',
>>>> +               new Ajax(Wiki.BasePath+'Search.action', {
>>>> +                       postBody:
>>>> "ajaxSearch=&"+$('searchform2').toQueryString(),
>>>> +                       update: 'searchResult2',
>>>>                       method: 'post',
>>>>                       onComplete: function() {
>>>>                               $('spin').hide();
>>>>
>>>> Modified:
>>>> incubator/jspwiki/trunk/src/WebContent/templates/default/ 
>>>> FindContent.jsp
>>>> URL:
>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/WebContent/templates/default/FindContent.jsp?rev=782495&r1=782494&r2=782495&view=diff
>>>>
>>>> === 
>>>> === 
>>>> === 
>>>> === 
>>>> ==================================================================
>>>> ---
>>>> incubator/jspwiki/trunk/src/WebContent/templates/default/ 
>>>> FindContent.jsp
>>>> (original)
>>>> +++
>>>> incubator/jspwiki/trunk/src/WebContent/templates/default/ 
>>>> FindContent.jsp Mon
>>>> Jun  8 01:37:33 2009
>>>> @@ -27,24 +27,18 @@
>>>> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
>>>> <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
>>>> <%@ page import="javax.servlet.jsp.jstl.fmt.*" %>
>>>> -<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld"
>>>> prefix="stripes" %>
>>>> +<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld"  
>>>> prefix="s" %>
>>>>
>>>> <wiki:TabbedSection>
>>>> <wiki:Tab id="findcontent" titleKey="find.tab" accesskey="s">
>>>>
>>>> -<form action="<wiki:Link format='url' jsp='Search.jsp'/>"
>>>> -       class="wikiform"
>>>> -          id="searchform2"
>>>> -         accept-charset="<wiki:ContentEncoding/>">
>>>> -
>>>> +<s:form beanclass="org.apache.wiki.action.SearchActionBean"
>>>> class="wikiform"
>>>> +    id="searchform2" acceptcharset="UTF-8">
>>>> +
>>>>  <h4><fmt:message key="find.input" /></h4>
>>>>  <p>
>>>> -    <input type="text"
>>>> -           name="query" id="query2"
>>>> -          value="<c:out value='${query}'/>"
>>>> -           size="32" />
>>>> -
>>>> -    <input type="checkbox" name="details" id="details" <c:if
>>>> test='${param.details == "on"}'>checked='checked'</c:if> />
>>>> +    <s:text name="query" id="query2" size="32" />
>>>> +    <s:checkbox name="details" id="details" />
>>>>    <fmt:message key="find.details" />
>>>>
>>>>    <select name="scope" id="scope">
>>>> @@ -55,16 +49,83 @@
>>>>      <option value="attachment:" <c:if test='${param.scope eq
>>>> "attachment:"}'>selected="selected"</c:if> ><fmt:message
>>>> key='find.scope.attach' /></option>
>>>>    </select>
>>>>
>>>> -       <input type="submit" name="ok" id="ok" value="<fmt:message
>>>> key="find.submit.find" />" />
>>>> -       <input type="submit" name="go" id="go" value="<fmt:message
>>>> key="find.submit.go" />" />
>>>> -    <input type="hidden" name="start" id="start" value="0" />
>>>> -    <input type="hidden" name="maxitems" id="maxitems"  
>>>> value="20" />
>>>> +    <s:submit name="search" id="ok" value="<fmt:message
>>>> key='find.submit.find' />" />
>>>> +    <s:submit name="go" id="go" value="<fmt:message  
>>>> key='find.submit.go'
>>>> />" />
>>>> +    <s:hidden name="start" id="start" value="0" />
>>>> +    <s:hidden name="maxItems" id="maxitems" value="20" />
>>>>
>>>>    <span id="spin" class="spin"
>>>> style="position:absolute;display:none;"></span>
>>>>  </p>
>>>> -</form>
>>>> +</s:form>
>>>> +
>>>> +<div id="searchResult2">
>>>> +  <wiki:SearchResults>
>>>> +
>>>> +    <h4><fmt:message key="find.heading.results"><fmt:param><c:out
>>>> value="${wikiActionBean.query}" /></fmt:param></fmt:message></h4>
>>>> +    <p>
>>>> +      <fmt:message key="find.externalsearch" />
>>>> +      <a class="external" href="http://www.google.com/search? 
>>>> q=<c:out
>>>> value='${wikiActionBean.query}' />" title="Google Search '<c:out
>>>> value='${wikiActionBean.query}' />'" target="_blank">Google</a><img
>>>> class="outlink" src="images/out.png" alt="" />
>>>> +      |
>>>> +      <a class="external" href="
>>>> http://en.wikipedia.org/wiki/Special:Search?search=<c:out
>>>> value='${wikiActionBean.query}' />" title="Wikipedia Search '<c:out
>>>> value='${wikiActionBean.query}' />'" target="_blank">Wikipedia</ 
>>>> a><img
>>>> class="outlink" src="images/out.png" alt="" />
>>>> +    </p>
>>>> +
>>>> +    <wiki:SetPagination start="${wikiActionBean.start}"
>>>> total="${wikiActionBean.resultsCount}" pagesize="20" maxlinks="9"
>>>> fmtkey="info.pagination" onclick="$('start').value=%s;
>>>> SearchBox.runfullsearch();" />
>>>> +
>>>> +    <div class="graphBars">
>>>> +      <div class="zebra-table">
>>>> +        <table class="wikitable">
>>>> +
>>>> +          <tr>
>>>> +             <th align="left"><fmt:message  
>>>> key="find.results.page" /></th>
>>>> +             <th align="left"><fmt:message  
>>>> key="find.results.score"
>>>> /></th>
>>>> +          </tr>
>>>> +
>>>> +          <wiki:SearchResultIterator id="searchref"
>>>> start="${wikiActionBean.start}" maxItems="$ 
>>>> {wikiActionBean.maxItems}">
>>>> +          <tr>
>>>> +            <td><wiki:LinkTo><wiki:PageName/></wiki:LinkTo></td>
>>>> +            <td><span class="gBar"><%= searchref.getScore() %></ 
>>>> span></td>
>>>> +          </tr>
>>>> +
>>>> +          <c:if test="${wikiActionBean.details == 'true'}">
>>>> +  <%
>>>> +            String[] contexts = searchref.getContexts();
>>>> +            if( (contexts != null) && (contexts.length > 0) )
>>>> +            {
>>>> +  %>
>>>> +          <tr class="odd">
>>>> +            <td colspan="2">
>>>> +              <div class="fragment">
>>>> +  <%
>>>> +              for (int i = 0; i < contexts.length; i++)
>>>> +              {
>>>> +  %>
>>>> +                <%= (i > 0 ) ? "<span  
>>>> class='fragment_ellipsis'> ...
>>>> </span>" : ""  %>
>>>> +                <%= contexts[i]  %>
>>>> +  <%
>>>> +              }
>>>> +  %>
>>>> +               </div>
>>>> +             </td>
>>>> +           </tr>
>>>> +  <%
>>>> +            }
>>>> +  %>
>>>> +          </c:if><%-- details --%>
>>>> +        </wiki:SearchResultIterator>
>>>> +
>>>> +        <wiki:IfNoSearchResults>
>>>> +          <tr>
>>>> +            <td class="nosearchresult" colspan="2"><fmt:message
>>>> key="find.noresults" /></td>
>>>> +          </tr>
>>>> +        </wiki:IfNoSearchResults>
>>>> +
>>>> +        </table>
>>>> +      </div>
>>>> +    </div>
>>>> +    ${pagination}
>>>>
>>>> -<div id="searchResult2"><wiki:Include page="AJAXSearch.jsp" /></ 
>>>> div>
>>>> +  </wiki:SearchResults>
>>>> +</div>
>>>>
>>>> </wiki:Tab>
>>>>
>>>>
>>>> Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/ 
>>>> WikiContext.java
>>>> URL:
>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiContext.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>
>>>> === 
>>>> === 
>>>> === 
>>>> === 
>>>> ==================================================================
>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/ 
>>>> WikiContext.java
>>>> (original)
>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/ 
>>>> WikiContext.java Mon
>>>> Jun  8 01:37:33 2009
>>>> @@ -103,7 +103,7 @@
>>>>    public static final String    COMMENT  =  
>>>> HandlerInfo.getHandlerInfo(
>>>> EditActionBean.class, "comment" ).getRequestContext();
>>>>
>>>>    /** User is searching for content. */
>>>> -    public static final String    FIND     =  
>>>> HandlerInfo.getHandlerInfo(
>>>> SearchActionBean.class, "find" ).getRequestContext();
>>>> +    public static final String    FIND     =  
>>>> HandlerInfo.getHandlerInfo(
>>>> SearchActionBean.class, "search" ).getRequestContext();
>>>>
>>>>    /** User wishes to create a new group */
>>>>    public static final String    CREATE_GROUP =
>>>> HandlerInfo.getHandlerInfo( GroupActionBean.class, "create"
>>>> ).getRequestContext();
>>>>
>>>> Modified:
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/action/ 
>>>> SearchActionBean.java
>>>> URL:
>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/action/SearchActionBean.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>
>>>> === 
>>>> === 
>>>> === 
>>>> === 
>>>> ==================================================================
>>>> ---
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/action/ 
>>>> SearchActionBean.java
>>>> (original)
>>>> +++
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/action/ 
>>>> SearchActionBean.java
>>>> Mon Jun  8 01:37:33 2009
>>>> @@ -21,18 +21,191 @@
>>>>
>>>> package org.apache.wiki.action;
>>>>
>>>> -import org.apache.wiki.ui.stripes.WikiRequestContext;
>>>> +import java.util.ArrayList;
>>>> +import java.util.Collection;
>>>> +import java.util.Collections;
>>>> +import java.util.List;
>>>>
>>>> import net.sourceforge.stripes.action.*;
>>>> +import net.sourceforge.stripes.ajax.JavaScriptResolution;
>>>> +
>>>> +import org.apache.wiki.WikiEngine;
>>>> +import org.apache.wiki.api.WikiPage;
>>>> +import org.apache.wiki.auth.AuthorizationManager;
>>>> +import org.apache.wiki.auth.permissions.PagePermission;
>>>> +import org.apache.wiki.log.Logger;
>>>> +import org.apache.wiki.log.LoggerFactory;
>>>> +import org.apache.wiki.search.SearchResult;
>>>> +import org.apache.wiki.ui.stripes.WikiRequestContext;
>>>>
>>>> +/**
>>>> + * Searches the WikiPage collection for a given wiki.
>>>> + */
>>>> @UrlBinding( "/Search.jsp" )
>>>> public class SearchActionBean extends AbstractActionBean
>>>> {
>>>> +    private Logger log = LoggerFactory.getLogger("JSPWikiSearch");
>>>> +
>>>> +    public static final Collection<SearchResult> NO_RESULTS =
>>>> Collections.emptyList();
>>>> +
>>>> +    private Collection<SearchResult> m_results = NO_RESULTS;
>>>> +
>>>> +    private String m_query = null;
>>>> +
>>>> +    private int m_maxItems = 20;
>>>> +
>>>> +    private int m_start = 0;
>>>> +
>>>> +    private boolean m_details = false;
>>>> +
>>>> +    public boolean getDetails()
>>>> +    {
>>>> +        return m_details;
>>>> +    }
>>>> +
>>>> +    /**
>>>> +     * Sets the search results so that details for each result are
>>>> displayed.
>>>> +     * @param details whether details should be displayed
>>>> +     */
>>>> +    public void setDetails( boolean details )
>>>> +    {
>>>> +        m_details = details;
>>>> +    }
>>>> +
>>>> +    public int getMaxItems()
>>>> +    {
>>>> +        return m_maxItems;
>>>> +    }
>>>> +
>>>> +    public void setMaxItems( int maxItems )
>>>> +    {
>>>> +        m_maxItems = maxItems;
>>>> +    }
>>>> +
>>>> +    public int getStart()
>>>> +    {
>>>> +        return m_start;
>>>> +    }
>>>> +
>>>> +    public void setStart( int start )
>>>> +    {
>>>> +        m_start = start;
>>>> +    }
>>>> +
>>>> +    /**
>>>> +     * Returns the query string for the search.
>>>> +     *
>>>> +     * @return the query string
>>>> +     */
>>>> +    public String getQuery()
>>>> +    {
>>>> +        return m_query;
>>>> +    }
>>>> +
>>>> +    /**
>>>> +     * Returns the results of the search.
>>>> +     *
>>>> +     * @return the results
>>>> +     */
>>>> +    public Collection<SearchResult> getResults()
>>>> +    {
>>>> +        return m_results;
>>>> +    }
>>>> +
>>>> +    /**
>>>> +     * Returns the number of items returned by the current search.
>>>> +     * @return the number of items
>>>> +     */
>>>> +    public int getResultsCount()
>>>> +    {
>>>> +        return m_results.size();
>>>> +    }
>>>> +
>>>> +    /**
>>>> +     * Performs a search and returns the results as a list. For  
>>>> a given
>>>> WikiPage to
>>>> +     * be included in the results, the user must have permission  
>>>> to view
>>>> it.
>>>> +     * If the underlying providers encounter an abnormal  
>>>> IOException or
>>>> other error,
>>>> +     * it will be added to the ActionBeanContext's validation  
>>>> messages
>>>> collection.
>>>> +     * @param query the query
>>>> +     * @return the results
>>>> +     */
>>>> +    private List<SearchResult> doSearch( String query )
>>>> +    {
>>>> +        log.info("Searching with query '"+ query + "'.");
>>>> +        WikiEngine engine = getContext().getEngine();
>>>> +        AuthorizationManager mgr =  
>>>> engine.getAuthorizationManager();
>>>> +
>>>> +        //
>>>> +        //  Filter down to only those that we actually have a  
>>>> permission
>>>> to view
>>>> +        //
>>>> +        List<SearchResult> filteredResults = new
>>>> ArrayList<SearchResult>();
>>>> +        try
>>>> +        {
>>>> +            List<SearchResult> results =  
>>>> engine.findPages( query );
>>>> +            for( SearchResult result : results )
>>>> +            {
>>>> +                WikiPage page = result.getPage();
>>>> +                PagePermission permission = new  
>>>> PagePermission( page,
>>>> PagePermission.VIEW_ACTION );
>>>> +                try
>>>> +                {
>>>> +                    if( mgr.checkPermission(
>>>> getContext().getWikiSession(), permission ) )
>>>> +                    {
>>>> +                        filteredResults.add( result );
>>>> +                    }
>>>> +                }
>>>> +                catch( Exception e ) { log.error( "Searching for  
>>>> page " +
>>>> page, e ); }
>>>> +            }
>>>> +        }
>>>> +        catch( Exception e )
>>>> +        {
>>>> +            log.debug( "Could not search using query '" + query  
>>>> + "'.", e
>>>> );
>>>> +            Message message = new SimpleMessage( e.getMessage() );
>>>> +            getContext().getMessages().add( message );
>>>> +            e.printStackTrace();
>>>> +        }
>>>> +        return filteredResults;
>>>> +    }
>>>> +
>>>> +    /**
>>>> +     * Sets the query string for the search.
>>>> +     *
>>>> +     * @param query the query string
>>>> +     */
>>>> +    public void setQuery( String query )
>>>> +    {
>>>> +        m_query = query;
>>>> +    }
>>>> +
>>>> +    /**
>>>> +     * Searches the wiki using the query string set for this
>>>> +     * ActionBean. Search results are made available to callers  
>>>> via the
>>>> +     * {@link #getResults()} method (and EL expression
>>>> +     * <code>$wikiActionBean.results</code>).
>>>> +     *
>>>> +     * @return always returns a {@link ForwardResolution} to
>>>> +     *         <code>/Search.jsp</code>.
>>>> +     */
>>>>    @DefaultHandler
>>>> -    @HandlesEvent( "find" )
>>>> +    @HandlesEvent( "search" )
>>>>    @WikiRequestContext( "find" )
>>>> -    public Resolution view()
>>>> +    public Resolution search()
>>>>    {
>>>> +        m_results = m_query == null ? NO_RESULTS :  
>>>> doSearch( m_query );
>>>>        return new ForwardResolution( "/Search.jsp" );
>>>>    }
>>>> +
>>>> +    /**
>>>> +     * Using AJAX, searches a specified wiki space using the  
>>>> query string
>>>> set for this
>>>> +     * ActionBean. Results are streamed back to the client as an  
>>>> array of
>>>> JSON-encoded
>>>> +     * SearchResult objects.
>>>> +     *
>>>> +     * @return always returns a {@link JavaScriptResolution}  
>>>> containing
>>>> the
>>>> +     * results; this may be a zero-length array
>>>> +     */
>>>> +    @HandlesEvent( "ajaxSearch" )
>>>> +    public Resolution ajaxSearch()
>>>> +    {
>>>> +        m_results = m_query == null ? NO_RESULTS :  
>>>> doSearch( m_query );
>>>> +        return new JavaScriptResolution( m_results );
>>>> +    }
>>>> }
>>>>
>>>> Modified:
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>> IfNoSearchResultsTag.java
>>>> URL:
>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IfNoSearchResultsTag.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>
>>>> === 
>>>> === 
>>>> === 
>>>> === 
>>>> ==================================================================
>>>> ---
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>> IfNoSearchResultsTag.java
>>>> (original)
>>>> +++
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>> IfNoSearchResultsTag.java
>>>> Mon Jun  8 01:37:33 2009
>>>> @@ -22,8 +22,8 @@
>>>>
>>>> import java.io.IOException;
>>>> import java.util.Collection;
>>>> -import javax.servlet.jsp.PageContext;
>>>>
>>>> +import org.apache.wiki.action.SearchActionBean;
>>>> import org.apache.wiki.search.SearchResult;
>>>>
>>>> /**
>>>> @@ -36,17 +36,18 @@
>>>> {
>>>>    private static final long serialVersionUID = 0L;
>>>>
>>>> -    @SuppressWarnings("unchecked")
>>>>    public final int doWikiStartTag()
>>>>        throws IOException
>>>>    {
>>>> -        Collection<SearchResult> list =
>>>> (Collection< 
>>>> SearchResult>)pageContext.getAttribute( "searchresults",
>>>> -
>>>> PageContext.REQUEST_SCOPE );
>>>> -        if( list == null || list.size() == 0 )
>>>> -        {
>>>> -            return EVAL_BODY_INCLUDE;
>>>> +        if ( m_wikiActionBean != null && m_wikiActionBean  
>>>> instanceof
>>>> SearchActionBean )
>>>> +        {
>>>> +            boolean emptyQuery =
>>>> ((SearchActionBean)m_wikiActionBean).getQuery() == null;
>>>> +            Collection<SearchResult> results =
>>>> ((SearchActionBean)m_wikiActionBean).getResults();
>>>> +            if ( emptyQuery || results.size() > 0 )
>>>> +            {
>>>> +                return SKIP_BODY;
>>>> +            }
>>>>        }
>>>> -
>>>> -        return SKIP_BODY;
>>>> +        return EVAL_BODY_INCLUDE;
>>>>    }
>>>> }
>>>>
>>>> Modified:
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>> SearchResultIteratorTag.java
>>>> URL:
>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultIteratorTag.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>
>>>> === 
>>>> === 
>>>> === 
>>>> === 
>>>> ==================================================================
>>>> ---
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>> SearchResultIteratorTag.java
>>>> (original)
>>>> +++
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>> SearchResultIteratorTag.java
>>>> Mon Jun  8 01:37:33 2009
>>>> @@ -20,12 +20,12 @@
>>>> */
>>>> package org.apache.wiki.tags;
>>>>
>>>> -import java.util.ArrayList;
>>>> import java.util.Collection;
>>>>
>>>> -import javax.servlet.jsp.PageContext;
>>>> -
>>>> +import org.apache.wiki.action.SearchActionBean;
>>>> +import org.apache.wiki.action.WikiActionBean;
>>>> import org.apache.wiki.search.SearchResult;
>>>> +import org.apache.wiki.ui.stripes.WikiInterceptor;
>>>>
>>>> /**
>>>> * Iterator tag for the current search results, as identified by a
>>>> @@ -36,19 +36,17 @@
>>>>    private static final long serialVersionUID = 1L;
>>>>
>>>>    /**
>>>> -     * \ Returns the list of SearchResults to iterate over.
>>>> +     * Returns the list of SearchResults to iterate over.
>>>>     */
>>>>    @Override
>>>> -    @SuppressWarnings( "unchecked" )
>>>>    protected Collection<SearchResult> initItems()
>>>>    {
>>>> -        Collection<SearchResult> results =  
>>>> (Collection<SearchResult>)
>>>> pageContext.getAttribute( "searchresults",
>>>> -
>>>>                     PageContext.REQUEST_SCOPE );
>>>> -        if( results == null )
>>>> +        WikiActionBean actionBean =  
>>>> WikiInterceptor.findActionBean(
>>>> pageContext );
>>>> +        if ( actionBean != null && actionBean instanceof  
>>>> SearchActionBean
>>>> )
>>>>        {
>>>> -            return new ArrayList<SearchResult>();
>>>> +            return ((SearchActionBean)actionBean).getResults();
>>>>        }
>>>> -        return results;
>>>> +        return SearchActionBean.NO_RESULTS;
>>>>    }
>>>>
>>>>    /**
>>>>
>>>> Modified:
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>> SearchResultsSizeTag.java
>>>> URL:
>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsSizeTag.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>
>>>> === 
>>>> === 
>>>> === 
>>>> === 
>>>> ==================================================================
>>>> ---
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>> SearchResultsSizeTag.java
>>>> (original)
>>>> +++
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>> SearchResultsSizeTag.java
>>>> Mon Jun  8 01:37:33 2009
>>>> @@ -22,8 +22,8 @@
>>>>
>>>> import java.io.IOException;
>>>> import java.util.Collection;
>>>> -import javax.servlet.jsp.PageContext;
>>>>
>>>> +import org.apache.wiki.action.SearchActionBean;
>>>> import org.apache.wiki.search.SearchResult;
>>>>
>>>> /**
>>>> @@ -37,17 +37,14 @@
>>>> {
>>>>    private static final long serialVersionUID = 0L;
>>>>
>>>> -    @SuppressWarnings("unchecked")
>>>>    public final int doWikiStartTag()
>>>>        throws IOException
>>>>    {
>>>> -        Collection<SearchResult> list =
>>>> (Collection< 
>>>> SearchResult>)pageContext.getAttribute( "searchresults",
>>>> -
>>>> PageContext.REQUEST_SCOPE );
>>>> -        if( list != null )
>>>> +        if ( m_wikiActionBean != null && m_wikiActionBean  
>>>> instanceof
>>>> SearchActionBean )
>>>>        {
>>>> -            pageContext.getOut().print( list.size() );
>>>> +            Collection<SearchResult> results =
>>>> ((SearchActionBean)m_wikiActionBean).getResults();
>>>> +            pageContext.getOut().print( results.size() );
>>>>        }
>>>> -
>>>>        return SKIP_BODY;
>>>>    }
>>>> }
>>>>
>>>> Modified:
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>> SearchResultsTag.java
>>>> URL:
>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsTag.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>
>>>> === 
>>>> === 
>>>> === 
>>>> === 
>>>> ==================================================================
>>>> ---
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>> SearchResultsTag.java
>>>> (original)
>>>> +++
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>> SearchResultsTag.java
>>>> Mon Jun  8 01:37:33 2009
>>>> @@ -21,10 +21,10 @@
>>>> package org.apache.wiki.tags;
>>>>
>>>> import java.io.IOException;
>>>> -import java.util.Collection;
>>>> +
>>>> import javax.servlet.jsp.PageContext;
>>>>
>>>> -import org.apache.wiki.search.SearchResult;
>>>> +import org.apache.wiki.action.SearchActionBean;
>>>>
>>>> /**
>>>> *  Includes the body content, if there are any search results.
>>>> @@ -36,16 +36,16 @@
>>>> {
>>>>    private static final long serialVersionUID = 0L;
>>>>
>>>> -    @SuppressWarnings("unchecked")
>>>>    public final int doWikiStartTag()
>>>>        throws IOException
>>>>    {
>>>> -        Collection<SearchResult> list =
>>>> (Collection< 
>>>> SearchResult>)pageContext.getAttribute( "searchresults",
>>>> -
>>>> PageContext.REQUEST_SCOPE );
>>>> -
>>>> -        if( list != null )
>>>> +        if ( m_wikiActionBean != null && m_wikiActionBean  
>>>> instanceof
>>>> SearchActionBean )
>>>>        {
>>>> -            return EVAL_BODY_INCLUDE;
>>>> +            boolean emptyQuery =
>>>> ((SearchActionBean)m_wikiActionBean).getQuery() == null;
>>>> +            if ( !emptyQuery )
>>>> +            {
>>>> +                return EVAL_BODY_INCLUDE;
>>>> +            }
>>>>        }
>>>>
>>>>        String message = (String)pageContext.getAttribute( "err",
>>>>
>>>>
>>>>
>>>
>
>
>>>> /**
>>>> *  Includes the body content, if there are any search results.
>>>> @@ -36,16 +36,16 @@
>>>> {
>>>>    private static final long serialVersionUID = 0L;
>>>>
>>>> -    @SuppressWarnings("unchecked")
>>>>    public final int doWikiStartTag()
>>>>        throws IOException
>>>>    {
>>>> -        Collection<SearchResult> list =
>>>> (Collection< 
>>>> SearchResult>)pageContext.getAttribute( "searchresults",
>>>> -
>>>> PageContext.REQUEST_SCOPE );
>>>> -
>>>> -        if( list != null )
>>>> +        if ( m_wikiActionBean != null && m_wikiActionBean  
>>>> instanceof
>>>> SearchActionBean )
>>>>        {
>>>> -            return EVAL_BODY_INCLUDE;
>>>> +            boolean emptyQuery =
>>>> ((SearchActionBean)m_wikiActionBean).getQuery() == null;
>>>> +            if ( !emptyQuery )
>>>> +            {
>>>> +                return EVAL_BODY_INCLUDE;
>>>> +            }
>>>>        }
>>>>
>>>>        String message = (String)pageContext.getAttribute( "err",
>>>>
>>>>
>>>>
>>>
>

Re: svn commit: r782495 - in /incubator/jspwiki/trunk/src: WebContent/ WebContent/scripts/ WebContent/templates/default/ java/org/apache/wiki/ java/org/apache/wiki/action/ java/org/apache/wiki/tags/

Posted by Andrew Jaquith <an...@gmail.com>.
Agreed. There are scenarios I can imagine where Stripes wouldn't fit.  
But for GETs and POSTs, it works well. If that means we can eliminate  
some complex code and maybe some JARs, that's even better.

On Jun 9, 2009, at 16:31, Janne Jalkanen <ja...@ecyrd.com>  
wrote:

>
> Yup, saw them.  Still wondering if it would be neater to build an  
> annotation for marking a bean handler method for JSON somehow. Or  
> support jabsorb-like discovery of ActionBean methods.
>
> Servlets do have one advantage though - Stripes supports only GET  
> and POST, which it treats completely similarly. HEAD, DELETE, PUT,  
> etc are not supported [which might be needed in a truly RESTful  
> API]. Also, since Stripes insists on parsing POST before it gets to  
> the ActionBean, in some instances you will need to bang it to its  
> senses.
>
> For example, if we still supported DAV, that could not be done with  
> Stripes without extending the Stripes DispatcherServlet.  Or if we  
> needed the actual POST body data in an ActionBean.
>
> (Also, we still have XML-RPC servlets, which I wouldn't touch...)
>
> /Janne
>
> On 9 Jun 2009, at 23:15, Andrew Jaquith wrote:
>
>> Janne, see my checked-in JSON notes in docs/ and also  
>> SearchActionBean for an example. Simply stated, ActionBean AJAX  
>> event methods need only return a JavaScriptResolution, the contents  
>> of which can be retrieved client-side by eval().
>>
>> Yes, the idea is to talk to the 'beans directly -- no need to  
>> "bridge" anything. A little creative @UrlBinding magic eliminates  
>> the need for servlets too. See what I've done with  
>> AttachActionBean...
>>
>> Andrew
>>
>> On Jun 9, 2009, at 15:24, Janne Jalkanen <ja...@ecyrd.com>  
>> wrote:
>>
>>>
>>> That would be good so we can get rid of jabsorb, jsonrpc and the  
>>> GlobalRPCBridge (which is amazingly huge, as documented by someone).
>>>
>>> I can probably do some hacking on the serverside over the weekend  
>>> as well.
>>>
>>> /Janne
>>>
>>> On 9 Jun 2009, at 21:03, Dirk Frederickx wrote:
>>>
>>>> Janne, Andrew,
>>>>
>>>>
>>>> Wiki.jsonrpc() is pretty much doing what you are  suggesting.
>>>> It just needs an update not to work anymore with JsonRPC but with  
>>>> hook-up
>>>> with Stripes' approach to ajax.
>>>>
>>>> This shouldn't be to hard to figure out.
>>>> I'll check this out over the weekend, unless anyone is moving  
>>>> faster ;-)
>>>>
>>>>
>>>> dirk
>>>>
>>>> On Mon, Jun 8, 2009 at 9:53 PM, Janne Jalkanen <janne.jalkanen@ecyrd.com 
>>>> >wrote:
>>>>
>>>>>
>>>>> Reminds me - the JS code used to call Ajax routines is  
>>>>> disgustingly
>>>>> loathsome and makes my eyes bleed and my stomach retch.  Can we  
>>>>> upgrade to a
>>>>> newer Mootools lib (1.2.2, I think) and switch to Request.JSON  
>>>>> and create a
>>>>> JSONFactory or an extension for creating our AJAX requests?
>>>>>
>>>>> Something like wiki.json( "Search", "ajaxSearch", { param1 :  
>>>>> value1, ... },
>>>>> callback(resultobj,resulttext) ); would be nice. This would  
>>>>> construct the
>>>>> URL to SearchActionBean, method ajaxSearch, with the given params.
>>>>>
>>>>> /Janne
>>>>>
>>>>> On 8 Jun 2009, at 21:52, Andrew Jaquith wrote:
>>>>>
>>>>> It will fix this one -- but only after we've hooked it up to the
>>>>>> client JavaScript. Should not take long.
>>>>>>
>>>>>> On Mon, Jun 8, 2009 at 2:44 PM, Harry Metske<harry.metske@gmail.com 
>>>>>> >
>>>>>> wrote:
>>>>>>
>>>>>>> Andrew,
>>>>>>>
>>>>>>> should this patch have fixed
>>>>>>> https://issues.apache.org/jira/browse/JSPWIKI-510 (only for  
>>>>>>> 3.0 of
>>>>>>> course) ?
>>>>>>>
>>>>>>> Harry
>>>>>>>
>>>>>>> 2009/6/8 <aj...@apache.org>
>>>>>>>
>>>>>>>
>>>>>>> Author: ajaquith
>>>>>>>> Date: Mon Jun  8 01:37:33 2009
>>>>>>>> New Revision: 782495
>>>>>>>>
>>>>>>>> URL: http://svn.apache.org/viewvc?rev=782495&view=rev
>>>>>>>> Log:
>>>>>>>> Search.jsp migrated to Stripes. SearchActionBean now provides  
>>>>>>>> searching
>>>>>>>> logic, including an ajaxSearch() method that filters results  
>>>>>>>> correctly
>>>>>>>> (this
>>>>>>>> is not hooked up to the client JavaScript yet, but it should be
>>>>>>>> straightforward to do). Still some i18n cleanup to do.
>>>>>>>>
>>>>>>>> Modified:
>>>>>>>> incubator/jspwiki/trunk/src/WebContent/Search.jsp
>>>>>>>> incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki- 
>>>>>>>> common.js
>>>>>>>>
>>>>>>>> incubator/jspwiki/trunk/src/WebContent/templates/default/ 
>>>>>>>> FindContent.jsp
>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ 
>>>>>>>> WikiContext.java
>>>>>>>>
>>>>>>>>
>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/action/ 
>>>>>>>> SearchActionBean.java
>>>>>>>>
>>>>>>>>
>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>>>> IfNoSearchResultsTag.java
>>>>>>>>
>>>>>>>>
>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>>>> SearchResultIteratorTag.java
>>>>>>>>
>>>>>>>>
>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>>>> SearchResultsSizeTag.java
>>>>>>>>
>>>>>>>>
>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>>>> SearchResultsTag.java
>>>>>>>>
>>>>>>>> Modified: incubator/jspwiki/trunk/src/WebContent/Search.jsp
>>>>>>>> URL:
>>>>>>>>
>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/WebContent/Search.jsp?rev=782495&r1=782494&r2=782495&view=diff
>>>>>>>>
>>>>>>>>
>>>>>>>> === 
>>>>>>>> === 
>>>>>>>> === 
>>>>>>>> === 
>>>>>>>> === 
>>>>>>>> ===============================================================
>>>>>>>> --- incubator/jspwiki/trunk/src/WebContent/Search.jsp  
>>>>>>>> (original)
>>>>>>>> +++ incubator/jspwiki/trunk/src/WebContent/Search.jsp Mon  
>>>>>>>> Jun  8
>>>>>>>> 01:37:33
>>>>>>>> 2009
>>>>>>>> @@ -18,108 +18,12 @@
>>>>>>>> specific language governing permissions and limitations
>>>>>>>> under the License.
>>>>>>>> --%>
>>>>>>>> -<%@ page import="org.apache.wiki.log.Logger" %>
>>>>>>>> -<%@ page import="org.apache.wiki.log.LoggerFactory" %>
>>>>>>>> -<%@ page import="org.apache.wiki.*" %>
>>>>>>>> -<%@ page import="org.apache.wiki.auth.*" %>
>>>>>>>> -<%@ page import="org.apache.wiki.auth.permissions.*" %>
>>>>>>>> -<%@ page import="java.util.*" %>
>>>>>>>> +<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld"  
>>>>>>>> prefix="s"
>>>>>>>> %>
>>>>>>>> <%@ page errorPage="/Error.jsp" %>
>>>>>>>> -<%@ page import="org.apache.wiki.search.*" %>
>>>>>>>> -<%@ taglib uri="http://jakarta.apache.org/jspwiki.tld"  
>>>>>>>> prefix="wiki"
>>>>>>>> %>
>>>>>>>> -<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld"
>>>>>>>> prefix="stripes" %>
>>>>>>>> -<%@ page import="org.apache.wiki.util.TextUtil" %>
>>>>>>>> -<%@ page import="org.apache.wiki.api.WikiPage" %>
>>>>>>>> -<stripes:useActionBean
>>>>>>>> beanclass="org.apache.wiki.action.SearchActionBean"
>>>>>>>> event="find" id="wikiActionBean" />
>>>>>>>> +<s:useActionBean  
>>>>>>>> beanclass="org.apache.wiki.action.SearchActionBean"
>>>>>>>> event="search" executeResolution="true" id="wikiActionBean" />
>>>>>>>> +<s:layout-render name="${templates['DefaultLayout.jsp']}">
>>>>>>>> +  <s:layout-component name="content">
>>>>>>>> +      <jsp:include page="${templates['FindContent.jsp']}" />
>>>>>>>> +  </s:layout-component>
>>>>>>>> +</s:layout-render>
>>>>>>>>
>>>>>>>> -<%!
>>>>>>>> -    Logger log = LoggerFactory.getLogger("JSPWikiSearch");
>>>>>>>> -%>
>>>>>>>> -
>>>>>>>> -<%
>>>>>>>> -    WikiEngine wiki =  
>>>>>>>> WikiEngine.getInstance( getServletConfig() );
>>>>>>>> -    // Create wiki context and check for authorization
>>>>>>>> -    WikiContext wikiContext = wiki.createContext( request,
>>>>>>>> WikiContext.FIND );
>>>>>>>> -    String pagereq = wikiContext.getPage().getName();
>>>>>>>> -
>>>>>>>> -    // Get the search results
>>>>>>>> -    Collection list = null;
>>>>>>>> -    String query = request.getParameter( "query");
>>>>>>>> -    String go    = request.getParameter("go");
>>>>>>>> -
>>>>>>>> -    if( query != null )
>>>>>>>> -    {
>>>>>>>> -        log.info("Searching for string "+query);
>>>>>>>> -
>>>>>>>> -        try
>>>>>>>> -        {
>>>>>>>> -            list = wiki.findPages( query );
>>>>>>>> -
>>>>>>>> -            //
>>>>>>>> -            //  Filter down to only those that we actually  
>>>>>>>> have a
>>>>>>>> permission to view
>>>>>>>> -            //
>>>>>>>> -            AuthorizationManager mgr =  
>>>>>>>> wiki.getAuthorizationManager();
>>>>>>>> -
>>>>>>>> -            ArrayList filteredList = new ArrayList();
>>>>>>>> -
>>>>>>>> -            for( Iterator i = list.iterator(); i.hasNext(); )
>>>>>>>> -            {
>>>>>>>> -                SearchResult r = (SearchResult)i.next();
>>>>>>>> -
>>>>>>>> -                WikiPage p = r.getPage();
>>>>>>>> -
>>>>>>>> -                PagePermission pp = new PagePermission( p,
>>>>>>>> PagePermission.VIEW_ACTION );
>>>>>>>> -
>>>>>>>> -                try
>>>>>>>> -                {
>>>>>>>> -                    if( mgr.checkPermission(
>>>>>>>> wikiContext.getWikiSession(),
>>>>>>>> pp ) )
>>>>>>>> -                    {
>>>>>>>> -                        filteredList.add( r );
>>>>>>>> -                    }
>>>>>>>> -                }
>>>>>>>> -                catch( Exception e ) { log.error( "Searching  
>>>>>>>> for page
>>>>>>>> "+p,
>>>>>>>> e ); }
>>>>>>>> -            }
>>>>>>>> -
>>>>>>>> -            pageContext.setAttribute( "searchresults",
>>>>>>>> -                                      filteredList,
>>>>>>>> -                                       
>>>>>>>> PageContext.REQUEST_SCOPE );
>>>>>>>> -        }
>>>>>>>> -        catch( Exception e )
>>>>>>>> -        {
>>>>>>>> -             
>>>>>>>> wikiContext.getWikiSession().addMessage( e.getMessage() );
>>>>>>>> -        }
>>>>>>>> -
>>>>>>>> -        query = TextUtil.replaceEntities( query );
>>>>>>>> -
>>>>>>>> -        pageContext.setAttribute( "query",
>>>>>>>> -                                  query,
>>>>>>>> -                                  PageContext.REQUEST_SCOPE );
>>>>>>>> -
>>>>>>>> -        //
>>>>>>>> -        //  Did the user click on "go"?
>>>>>>>> -        //
>>>>>>>> -        if( go != null )
>>>>>>>> -        {
>>>>>>>> -            if( list != null && list.size() > 0 )
>>>>>>>> -            {
>>>>>>>> -                SearchResult sr = (SearchResult)
>>>>>>>> list.iterator().next();
>>>>>>>> -
>>>>>>>> -                WikiPage wikiPage = sr.getPage();
>>>>>>>> -
>>>>>>>> -                String url =  
>>>>>>>> wikiContext.getViewURL( wikiPage.getName()
>>>>>>>> );
>>>>>>>> -
>>>>>>>> -                response.sendRedirect( url );
>>>>>>>> -
>>>>>>>> -                return;
>>>>>>>> -            }
>>>>>>>> -        }
>>>>>>>> -    }
>>>>>>>> -
>>>>>>>> -    // Set the content type and include the response content
>>>>>>>> -    response.setContentType("text/html;
>>>>>>>> charset="+wiki.getContentEncoding() );
>>>>>>>> -    String contentPage = wiki.getTemplateManager().findJSP(
>>>>>>>> pageContext,
>>>>>>>> -
>>>>>>>> wikiContext.getTemplate(),
>>>>>>>> -
>>>>>>>> "ViewTemplate.jsp" );
>>>>>>>> -%><wiki:Include page="<%=contentPage%>" /><%
>>>>>>>> -    log.debug("SEARCH COMPLETE");
>>>>>>>> -%>
>>>>>>>>
>>>>>>>> Modified:
>>>>>>>> incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki- 
>>>>>>>> common.js
>>>>>>>> URL:
>>>>>>>>
>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-common.js?rev=782495&r1=782494&r2=782495&view=diff
>>>>>>>>
>>>>>>>>
>>>>>>>> === 
>>>>>>>> === 
>>>>>>>> === 
>>>>>>>> === 
>>>>>>>> === 
>>>>>>>> ===============================================================
>>>>>>>> --- incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki- 
>>>>>>>> common.js
>>>>>>>> (original)
>>>>>>>> +++ incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki- 
>>>>>>>> common.js Mon
>>>>>>>> Jun  8 01:37:33 2009
>>>>>>>> @@ -931,9 +931,9 @@
>>>>>>>>                   if (option.value == match) option.selected  
>>>>>>>> = true;
>>>>>>>>           });
>>>>>>>>
>>>>>>>> -               new Ajax(Wiki.TemplateUrl+'AJAXSearch.jsp', {
>>>>>>>> -                       postBody: $ 
>>>>>>>> ('searchform2').toQueryString(),
>>>>>>>> -                       update: 'searchResult2',
>>>>>>>> +               new Ajax(Wiki.BasePath+'Search.action', {
>>>>>>>> +                       postBody:
>>>>>>>> "ajaxSearch=&"+$('searchform2').toQueryString(),
>>>>>>>> +                       update: 'searchResult2',
>>>>>>>>                   method: 'post',
>>>>>>>>                   onComplete: function() {
>>>>>>>>                           $('spin').hide();
>>>>>>>>
>>>>>>>> Modified:
>>>>>>>> incubator/jspwiki/trunk/src/WebContent/templates/default/ 
>>>>>>>> FindContent.jsp
>>>>>>>> URL:
>>>>>>>>
>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/WebContent/templates/default/FindContent.jsp?rev=782495&r1=782494&r2=782495&view=diff
>>>>>>>>
>>>>>>>>
>>>>>>>> === 
>>>>>>>> === 
>>>>>>>> === 
>>>>>>>> === 
>>>>>>>> === 
>>>>>>>> ===============================================================
>>>>>>>> ---
>>>>>>>> incubator/jspwiki/trunk/src/WebContent/templates/default/ 
>>>>>>>> FindContent.jsp
>>>>>>>> (original)
>>>>>>>> +++
>>>>>>>> incubator/jspwiki/trunk/src/WebContent/templates/default/ 
>>>>>>>> FindContent.jsp
>>>>>>>> Mon
>>>>>>>> Jun  8 01:37:33 2009
>>>>>>>> @@ -27,24 +27,18 @@
>>>>>>>> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"  
>>>>>>>> %>
>>>>>>>> <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt"  
>>>>>>>> prefix="fmt" %>
>>>>>>>> <%@ page import="javax.servlet.jsp.jstl.fmt.*" %>
>>>>>>>> -<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld"
>>>>>>>> prefix="stripes" %>
>>>>>>>> +<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld"  
>>>>>>>> prefix="s"
>>>>>>>> %>
>>>>>>>>
>>>>>>>> <wiki:TabbedSection>
>>>>>>>> <wiki:Tab id="findcontent" titleKey="find.tab" accesskey="s">
>>>>>>>>
>>>>>>>> -<form action="<wiki:Link format='url' jsp='Search.jsp'/>"
>>>>>>>> -       class="wikiform"
>>>>>>>> -          id="searchform2"
>>>>>>>> -         accept-charset="<wiki:ContentEncoding/>">
>>>>>>>> -
>>>>>>>> +<s:form beanclass="org.apache.wiki.action.SearchActionBean"
>>>>>>>> class="wikiform"
>>>>>>>> +    id="searchform2" acceptcharset="UTF-8">
>>>>>>>> +
>>>>>>>> <h4><fmt:message key="find.input" /></h4>
>>>>>>>> <p>
>>>>>>>> -    <input type="text"
>>>>>>>> -           name="query" id="query2"
>>>>>>>> -          value="<c:out value='${query}'/>"
>>>>>>>> -           size="32" />
>>>>>>>> -
>>>>>>>> -    <input type="checkbox" name="details" id="details" <c:if
>>>>>>>> test='${param.details == "on"}'>checked='checked'</c:if> />
>>>>>>>> +    <s:text name="query" id="query2" size="32" />
>>>>>>>> +    <s:checkbox name="details" id="details" />
>>>>>>>> <fmt:message key="find.details" />
>>>>>>>>
>>>>>>>> <select name="scope" id="scope">
>>>>>>>> @@ -55,16 +49,83 @@
>>>>>>>>  <option value="attachment:" <c:if test='${param.scope eq
>>>>>>>> "attachment:"}'>selected="selected"</c:if> ><fmt:message
>>>>>>>> key='find.scope.attach' /></option>
>>>>>>>> </select>
>>>>>>>>
>>>>>>>> -       <input type="submit" name="ok" id="ok"  
>>>>>>>> value="<fmt:message
>>>>>>>> key="find.submit.find" />" />
>>>>>>>> -       <input type="submit" name="go" id="go"  
>>>>>>>> value="<fmt:message
>>>>>>>> key="find.submit.go" />" />
>>>>>>>> -    <input type="hidden" name="start" id="start" value="0" />
>>>>>>>> -    <input type="hidden" name="maxitems" id="maxitems"  
>>>>>>>> value="20" />
>>>>>>>> +    <s:submit name="search" id="ok" value="<fmt:message
>>>>>>>> key='find.submit.find' />" />
>>>>>>>> +    <s:submit name="go" id="go" value="<fmt:message
>>>>>>>> key='find.submit.go'
>>>>>>>> />" />
>>>>>>>> +    <s:hidden name="start" id="start" value="0" />
>>>>>>>> +    <s:hidden name="maxItems" id="maxitems" value="20" />
>>>>>>>>
>>>>>>>> <span id="spin" class="spin"
>>>>>>>> style="position:absolute;display:none;"></span>
>>>>>>>> </p>
>>>>>>>> -</form>
>>>>>>>> +</s:form>
>>>>>>>> +
>>>>>>>> +<div id="searchResult2">
>>>>>>>> +  <wiki:SearchResults>
>>>>>>>> +
>>>>>>>> +    <h4><fmt:message  
>>>>>>>> key="find.heading.results"><fmt:param><c:out
>>>>>>>> value="${wikiActionBean.query}" /></fmt:param></fmt:message></ 
>>>>>>>> h4>
>>>>>>>> +    <p>
>>>>>>>> +      <fmt:message key="find.externalsearch" />
>>>>>>>> +      <a class="external" href="http://www.google.com/search?q= 
>>>>>>>> <c:out
>>>>>>>> value='${wikiActionBean.query}' />" title="Google Search  
>>>>>>>> '<c:out
>>>>>>>> value='${wikiActionBean.query}' />'" target="_blank">Google</ 
>>>>>>>> a><img
>>>>>>>> class="outlink" src="images/out.png" alt="" />
>>>>>>>> +      |
>>>>>>>> +      <a class="external" href="
>>>>>>>> http://en.wikipedia.org/wiki/Special:Search?search=<c:out
>>>>>>>> value='${wikiActionBean.query}' />" title="Wikipedia Search  
>>>>>>>> '<c:out
>>>>>>>> value='${wikiActionBean.query}' />'"  
>>>>>>>> target="_blank">Wikipedia</a><img
>>>>>>>> class="outlink" src="images/out.png" alt="" />
>>>>>>>> +    </p>
>>>>>>>> +
>>>>>>>> +    <wiki:SetPagination start="${wikiActionBean.start}"
>>>>>>>> total="${wikiActionBean.resultsCount}" pagesize="20"  
>>>>>>>> maxlinks="9"
>>>>>>>> fmtkey="info.pagination" onclick="$('start').value=%s;
>>>>>>>> SearchBox.runfullsearch();" />
>>>>>>>> +
>>>>>>>> +    <div class="graphBars">
>>>>>>>> +      <div class="zebra-table">
>>>>>>>> +        <table class="wikitable">
>>>>>>>> +
>>>>>>>> +          <tr>
>>>>>>>> +             <th align="left"><fmt:message  
>>>>>>>> key="find.results.page"
>>>>>>>> /></th>
>>>>>>>> +             <th align="left"><fmt:message  
>>>>>>>> key="find.results.score"
>>>>>>>> /></th>
>>>>>>>> +          </tr>
>>>>>>>> +
>>>>>>>> +          <wiki:SearchResultIterator id="searchref"
>>>>>>>> start="${wikiActionBean.start}" maxItems="$ 
>>>>>>>> {wikiActionBean.maxItems}">
>>>>>>>> +          <tr>
>>>>>>>> +            <td><wiki:LinkTo><wiki:PageName/></wiki:LinkTo></ 
>>>>>>>> td>
>>>>>>>> +            <td><span class="gBar"><%= searchref.getScore()
>>>>>>>> %></span></td>
>>>>>>>> +          </tr>
>>>>>>>> +
>>>>>>>> +          <c:if test="${wikiActionBean.details == 'true'}">
>>>>>>>> +  <%
>>>>>>>> +            String[] contexts = searchref.getContexts();
>>>>>>>> +            if( (contexts != null) && (contexts.length > 0) )
>>>>>>>> +            {
>>>>>>>> +  %>
>>>>>>>> +          <tr class="odd">
>>>>>>>> +            <td colspan="2">
>>>>>>>> +              <div class="fragment">
>>>>>>>> +  <%
>>>>>>>> +              for (int i = 0; i < contexts.length; i++)
>>>>>>>> +              {
>>>>>>>> +  %>
>>>>>>>> +                <%= (i > 0 ) ? "<span  
>>>>>>>> class='fragment_ellipsis'> ...
>>>>>>>> </span>" : ""  %>
>>>>>>>> +                <%= contexts[i]  %>
>>>>>>>> +  <%
>>>>>>>> +              }
>>>>>>>> +  %>
>>>>>>>> +               </div>
>>>>>>>> +             </td>
>>>>>>>> +           </tr>
>>>>>>>> +  <%
>>>>>>>> +            }
>>>>>>>> +  %>
>>>>>>>> +          </c:if><%-- details --%>
>>>>>>>> +        </wiki:SearchResultIterator>
>>>>>>>> +
>>>>>>>> +        <wiki:IfNoSearchResults>
>>>>>>>> +          <tr>
>>>>>>>> +            <td class="nosearchresult"  
>>>>>>>> colspan="2"><fmt:message
>>>>>>>> key="find.noresults" /></td>
>>>>>>>> +          </tr>
>>>>>>>> +        </wiki:IfNoSearchResults>
>>>>>>>> +
>>>>>>>> +        </table>
>>>>>>>> +      </div>
>>>>>>>> +    </div>
>>>>>>>> +    ${pagination}
>>>>>>>>
>>>>>>>> -<div id="searchResult2"><wiki:Include page="AJAXSearch.jsp" / 
>>>>>>>> ></div>
>>>>>>>> +  </wiki:SearchResults>
>>>>>>>> +</div>
>>>>>>>>
>>>>>>>> </wiki:Tab>
>>>>>>>>
>>>>>>>>
>>>>>>>> Modified:
>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ 
>>>>>>>> WikiContext.java
>>>>>>>> URL:
>>>>>>>>
>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiContext.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>>>>>
>>>>>>>>
>>>>>>>> === 
>>>>>>>> === 
>>>>>>>> === 
>>>>>>>> === 
>>>>>>>> === 
>>>>>>>> ===============================================================
>>>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/ 
>>>>>>>> WikiContext.java
>>>>>>>> (original)
>>>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/ 
>>>>>>>> WikiContext.java
>>>>>>>> Mon
>>>>>>>> Jun  8 01:37:33 2009
>>>>>>>> @@ -103,7 +103,7 @@
>>>>>>>> public static final String    COMMENT  =  
>>>>>>>> HandlerInfo.getHandlerInfo(
>>>>>>>> EditActionBean.class, "comment" ).getRequestContext();
>>>>>>>>
>>>>>>>> /** User is searching for content. */
>>>>>>>> -    public static final String    FIND     =
>>>>>>>> HandlerInfo.getHandlerInfo(
>>>>>>>> SearchActionBean.class, "find" ).getRequestContext();
>>>>>>>> +    public static final String    FIND     =
>>>>>>>> HandlerInfo.getHandlerInfo(
>>>>>>>> SearchActionBean.class, "search" ).getRequestContext();
>>>>>>>>
>>>>>>>> /** User wishes to create a new group */
>>>>>>>> public static final String    CREATE_GROUP =
>>>>>>>> HandlerInfo.getHandlerInfo( GroupActionBean.class, "create"
>>>>>>>> ).getRequestContext();
>>>>>>>>
>>>>>>>> Modified:
>>>>>>>>
>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/action/ 
>>>>>>>> SearchActionBean.java
>>>>>>>> URL:
>>>>>>>>
>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/action/SearchActionBean.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>>>>>
>>>>>>>>
>>>>>>>> === 
>>>>>>>> === 
>>>>>>>> === 
>>>>>>>> === 
>>>>>>>> === 
>>>>>>>> ===============================================================
>>>>>>>> ---
>>>>>>>>
>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/action/ 
>>>>>>>> SearchActionBean.java
>>>>>>>> (original)
>>>>>>>> +++
>>>>>>>>
>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/action/ 
>>>>>>>> SearchActionBean.java
>>>>>>>> Mon Jun  8 01:37:33 2009
>>>>>>>> @@ -21,18 +21,191 @@
>>>>>>>>
>>>>>>>> package org.apache.wiki.action;
>>>>>>>>
>>>>>>>> -import org.apache.wiki.ui.stripes.WikiRequestContext;
>>>>>>>> +import java.util.ArrayList;
>>>>>>>> +import java.util.Collection;
>>>>>>>> +import java.util.Collections;
>>>>>>>> +import java.util.List;
>>>>>>>>
>>>>>>>> import net.sourceforge.stripes.action.*;
>>>>>>>> +import net.sourceforge.stripes.ajax.JavaScriptResolution;
>>>>>>>> +
>>>>>>>> +import org.apache.wiki.WikiEngine;
>>>>>>>> +import org.apache.wiki.api.WikiPage;
>>>>>>>> +import org.apache.wiki.auth.AuthorizationManager;
>>>>>>>> +import org.apache.wiki.auth.permissions.PagePermission;
>>>>>>>> +import org.apache.wiki.log.Logger;
>>>>>>>> +import org.apache.wiki.log.LoggerFactory;
>>>>>>>> +import org.apache.wiki.search.SearchResult;
>>>>>>>> +import org.apache.wiki.ui.stripes.WikiRequestContext;
>>>>>>>>
>>>>>>>> +/**
>>>>>>>> + * Searches the WikiPage collection for a given wiki.
>>>>>>>> + */
>>>>>>>> @UrlBinding( "/Search.jsp" )
>>>>>>>> public class SearchActionBean extends AbstractActionBean
>>>>>>>> {
>>>>>>>> +    private Logger log =  
>>>>>>>> LoggerFactory.getLogger("JSPWikiSearch");
>>>>>>>> +
>>>>>>>> +    public static final Collection<SearchResult> NO_RESULTS =
>>>>>>>> Collections.emptyList();
>>>>>>>> +
>>>>>>>> +    private Collection<SearchResult> m_results = NO_RESULTS;
>>>>>>>> +
>>>>>>>> +    private String m_query = null;
>>>>>>>> +
>>>>>>>> +    private int m_maxItems = 20;
>>>>>>>> +
>>>>>>>> +    private int m_start = 0;
>>>>>>>> +
>>>>>>>> +    private boolean m_details = false;
>>>>>>>> +
>>>>>>>> +    public boolean getDetails()
>>>>>>>> +    {
>>>>>>>> +        return m_details;
>>>>>>>> +    }
>>>>>>>> +
>>>>>>>> +    /**
>>>>>>>> +     * Sets the search results so that details for each  
>>>>>>>> result are
>>>>>>>> displayed.
>>>>>>>> +     * @param details whether details should be displayed
>>>>>>>> +     */
>>>>>>>> +    public void setDetails( boolean details )
>>>>>>>> +    {
>>>>>>>> +        m_details = details;
>>>>>>>> +    }
>>>>>>>> +
>>>>>>>> +    public int getMaxItems()
>>>>>>>> +    {
>>>>>>>> +        return m_maxItems;
>>>>>>>> +    }
>>>>>>>> +
>>>>>>>> +    public void setMaxItems( int maxItems )
>>>>>>>> +    {
>>>>>>>> +        m_maxItems = maxItems;
>>>>>>>> +    }
>>>>>>>> +
>>>>>>>> +    public int getStart()
>>>>>>>> +    {
>>>>>>>> +        return m_start;
>>>>>>>> +    }
>>>>>>>> +
>>>>>>>> +    public void setStart( int start )
>>>>>>>> +    {
>>>>>>>> +        m_start = start;
>>>>>>>> +    }
>>>>>>>> +
>>>>>>>> +    /**
>>>>>>>> +     * Returns the query string for the search.
>>>>>>>> +     *
>>>>>>>> +     * @return the query string
>>>>>>>> +     */
>>>>>>>> +    public String getQuery()
>>>>>>>> +    {
>>>>>>>> +        return m_query;
>>>>>>>> +    }
>>>>>>>> +
>>>>>>>> +    /**
>>>>>>>> +     * Returns the results of the search.
>>>>>>>> +     *
>>>>>>>> +     * @return the results
>>>>>>>> +     */
>>>>>>>> +    public Collection<SearchResult> getResults()
>>>>>>>> +    {
>>>>>>>> +        return m_results;
>>>>>>>> +    }
>>>>>>>> +
>>>>>>>> +    /**
>>>>>>>> +     * Returns the number of items returned by the current  
>>>>>>>> search.
>>>>>>>> +     * @return the number of items
>>>>>>>> +     */
>>>>>>>> +    public int getResultsCount()
>>>>>>>> +    {
>>>>>>>> +        return m_results.size();
>>>>>>>> +    }
>>>>>>>> +
>>>>>>>> +    /**
>>>>>>>> +     * Performs a search and returns the results as a list.  
>>>>>>>> For a given
>>>>>>>> WikiPage to
>>>>>>>> +     * be included in the results, the user must have  
>>>>>>>> permission to
>>>>>>>> view
>>>>>>>> it.
>>>>>>>> +     * If the underlying providers encounter an abnormal  
>>>>>>>> IOException or
>>>>>>>> other error,
>>>>>>>> +     * it will be added to the ActionBeanContext's  
>>>>>>>> validation messages
>>>>>>>> collection.
>>>>>>>> +     * @param query the query
>>>>>>>> +     * @return the results
>>>>>>>> +     */
>>>>>>>> +    private List<SearchResult> doSearch( String query )
>>>>>>>> +    {
>>>>>>>> +        log.info("Searching with query '"+ query + "'.");
>>>>>>>> +        WikiEngine engine = getContext().getEngine();
>>>>>>>> +        AuthorizationManager mgr =  
>>>>>>>> engine.getAuthorizationManager();
>>>>>>>> +
>>>>>>>> +        //
>>>>>>>> +        //  Filter down to only those that we actually have a
>>>>>>>> permission
>>>>>>>> to view
>>>>>>>> +        //
>>>>>>>> +        List<SearchResult> filteredResults = new
>>>>>>>> ArrayList<SearchResult>();
>>>>>>>> +        try
>>>>>>>> +        {
>>>>>>>> +            List<SearchResult> results =  
>>>>>>>> engine.findPages( query );
>>>>>>>> +            for( SearchResult result : results )
>>>>>>>> +            {
>>>>>>>> +                WikiPage page = result.getPage();
>>>>>>>> +                PagePermission permission = new  
>>>>>>>> PagePermission( page,
>>>>>>>> PagePermission.VIEW_ACTION );
>>>>>>>> +                try
>>>>>>>> +                {
>>>>>>>> +                    if( mgr.checkPermission(
>>>>>>>> getContext().getWikiSession(), permission ) )
>>>>>>>> +                    {
>>>>>>>> +                        filteredResults.add( result );
>>>>>>>> +                    }
>>>>>>>> +                }
>>>>>>>> +                catch( Exception e ) { log.error( "Searching  
>>>>>>>> for page "
>>>>>>>> +
>>>>>>>> page, e ); }
>>>>>>>> +            }
>>>>>>>> +        }
>>>>>>>> +        catch( Exception e )
>>>>>>>> +        {
>>>>>>>> +            log.debug( "Could not search using query '" +  
>>>>>>>> query + "'.",
>>>>>>>> e
>>>>>>>> );
>>>>>>>> +            Message message = new  
>>>>>>>> SimpleMessage( e.getMessage() );
>>>>>>>> +            getContext().getMessages().add( message );
>>>>>>>> +            e.printStackTrace();
>>>>>>>> +        }
>>>>>>>> +        return filteredResults;
>>>>>>>> +    }
>>>>>>>> +
>>>>>>>> +    /**
>>>>>>>> +     * Sets the query string for the search.
>>>>>>>> +     *
>>>>>>>> +     * @param query the query string
>>>>>>>> +     */
>>>>>>>> +    public void setQuery( String query )
>>>>>>>> +    {
>>>>>>>> +        m_query = query;
>>>>>>>> +    }
>>>>>>>> +
>>>>>>>> +    /**
>>>>>>>> +     * Searches the wiki using the query string set for this
>>>>>>>> +     * ActionBean. Search results are made available to  
>>>>>>>> callers via the
>>>>>>>> +     * {@link #getResults()} method (and EL expression
>>>>>>>> +     * <code>$wikiActionBean.results</code>).
>>>>>>>> +     *
>>>>>>>> +     * @return always returns a {@link ForwardResolution} to
>>>>>>>> +     *         <code>/Search.jsp</code>.
>>>>>>>> +     */
>>>>>>>> @DefaultHandler
>>>>>>>> -    @HandlesEvent( "find" )
>>>>>>>> +    @HandlesEvent( "search" )
>>>>>>>> @WikiRequestContext( "find" )
>>>>>>>> -    public Resolution view()
>>>>>>>> +    public Resolution search()
>>>>>>>> {
>>>>>>>> +        m_results = m_query == null ? NO_RESULTS :  
>>>>>>>> doSearch( m_query );
>>>>>>>>    return new ForwardResolution( "/Search.jsp" );
>>>>>>>> }
>>>>>>>> +
>>>>>>>> +    /**
>>>>>>>> +     * Using AJAX, searches a specified wiki space using the  
>>>>>>>> query
>>>>>>>> string
>>>>>>>> set for this
>>>>>>>> +     * ActionBean. Results are streamed back to the client  
>>>>>>>> as an array
>>>>>>>> of
>>>>>>>> JSON-encoded
>>>>>>>> +     * SearchResult objects.
>>>>>>>> +     *
>>>>>>>> +     * @return always returns a {@link JavaScriptResolution}  
>>>>>>>> containing
>>>>>>>> the
>>>>>>>> +     * results; this may be a zero-length array
>>>>>>>> +     */
>>>>>>>> +    @HandlesEvent( "ajaxSearch" )
>>>>>>>> +    public Resolution ajaxSearch()
>>>>>>>> +    {
>>>>>>>> +        m_results = m_query == null ? NO_RESULTS :  
>>>>>>>> doSearch( m_query );
>>>>>>>> +        return new JavaScriptResolution( m_results );
>>>>>>>> +    }
>>>>>>>> }
>>>>>>>>
>>>>>>>> Modified:
>>>>>>>>
>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>>>> IfNoSearchResultsTag.java
>>>>>>>> URL:
>>>>>>>>
>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IfNoSearchResultsTag.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>>>>>
>>>>>>>>
>>>>>>>> === 
>>>>>>>> === 
>>>>>>>> === 
>>>>>>>> === 
>>>>>>>> === 
>>>>>>>> ===============================================================
>>>>>>>> ---
>>>>>>>>
>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>>>> IfNoSearchResultsTag.java
>>>>>>>> (original)
>>>>>>>> +++
>>>>>>>>
>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>>>> IfNoSearchResultsTag.java
>>>>>>>> Mon Jun  8 01:37:33 2009
>>>>>>>> @@ -22,8 +22,8 @@
>>>>>>>>
>>>>>>>> import java.io.IOException;
>>>>>>>> import java.util.Collection;
>>>>>>>> -import javax.servlet.jsp.PageContext;
>>>>>>>>
>>>>>>>> +import org.apache.wiki.action.SearchActionBean;
>>>>>>>> import org.apache.wiki.search.SearchResult;
>>>>>>>>
>>>>>>>> /**
>>>>>>>> @@ -36,17 +36,18 @@
>>>>>>>> {
>>>>>>>> private static final long serialVersionUID = 0L;
>>>>>>>>
>>>>>>>> -    @SuppressWarnings("unchecked")
>>>>>>>> public final int doWikiStartTag()
>>>>>>>>    throws IOException
>>>>>>>> {
>>>>>>>> -        Collection<SearchResult> list =
>>>>>>>> (Collection< 
>>>>>>>> SearchResult>)pageContext.getAttribute( "searchresults",
>>>>>>>> -
>>>>>>>> PageContext.REQUEST_SCOPE );
>>>>>>>> -        if( list == null || list.size() == 0 )
>>>>>>>> -        {
>>>>>>>> -            return EVAL_BODY_INCLUDE;
>>>>>>>> +        if ( m_wikiActionBean != null && m_wikiActionBean  
>>>>>>>> instanceof
>>>>>>>> SearchActionBean )
>>>>>>>> +        {
>>>>>>>> +            boolean emptyQuery =
>>>>>>>> ((SearchActionBean)m_wikiActionBean).getQuery() == null;
>>>>>>>> +            Collection<SearchResult> results =
>>>>>>>> ((SearchActionBean)m_wikiActionBean).getResults();
>>>>>>>> +            if ( emptyQuery || results.size() > 0 )
>>>>>>>> +            {
>>>>>>>> +                return SKIP_BODY;
>>>>>>>> +            }
>>>>>>>>    }
>>>>>>>> -
>>>>>>>> -        return SKIP_BODY;
>>>>>>>> +        return EVAL_BODY_INCLUDE;
>>>>>>>> }
>>>>>>>> }
>>>>>>>>
>>>>>>>> Modified:
>>>>>>>>
>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>>>> SearchResultIteratorTag.java
>>>>>>>> URL:
>>>>>>>>
>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultIteratorTag.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>>>>>
>>>>>>>>
>>>>>>>> === 
>>>>>>>> === 
>>>>>>>> === 
>>>>>>>> === 
>>>>>>>> === 
>>>>>>>> ===============================================================
>>>>>>>> ---
>>>>>>>>
>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>>>> SearchResultIteratorTag.java
>>>>>>>> (original)
>>>>>>>> +++
>>>>>>>>
>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>>>> SearchResultIteratorTag.java
>>>>>>>> Mon Jun  8 01:37:33 2009
>>>>>>>> @@ -20,12 +20,12 @@
>>>>>>>> */
>>>>>>>> package org.apache.wiki.tags;
>>>>>>>>
>>>>>>>> -import java.util.ArrayList;
>>>>>>>> import java.util.Collection;
>>>>>>>>
>>>>>>>> -import javax.servlet.jsp.PageContext;
>>>>>>>> -
>>>>>>>> +import org.apache.wiki.action.SearchActionBean;
>>>>>>>> +import org.apache.wiki.action.WikiActionBean;
>>>>>>>> import org.apache.wiki.search.SearchResult;
>>>>>>>> +import org.apache.wiki.ui.stripes.WikiInterceptor;
>>>>>>>>
>>>>>>>> /**
>>>>>>>> * Iterator tag for the current search results, as identified  
>>>>>>>> by a
>>>>>>>> @@ -36,19 +36,17 @@
>>>>>>>> private static final long serialVersionUID = 1L;
>>>>>>>>
>>>>>>>> /**
>>>>>>>> -     * \ Returns the list of SearchResults to iterate over.
>>>>>>>> +     * Returns the list of SearchResults to iterate over.
>>>>>>>> */
>>>>>>>> @Override
>>>>>>>> -    @SuppressWarnings( "unchecked" )
>>>>>>>> protected Collection<SearchResult> initItems()
>>>>>>>> {
>>>>>>>> -        Collection<SearchResult> results =  
>>>>>>>> (Collection<SearchResult>)
>>>>>>>> pageContext.getAttribute( "searchresults",
>>>>>>>> -
>>>>>>>>                 PageContext.REQUEST_SCOPE );
>>>>>>>> -        if( results == null )
>>>>>>>> +        WikiActionBean actionBean =  
>>>>>>>> WikiInterceptor.findActionBean(
>>>>>>>> pageContext );
>>>>>>>> +        if ( actionBean != null && actionBean instanceof
>>>>>>>> SearchActionBean
>>>>>>>> )
>>>>>>>>    {
>>>>>>>> -            return new ArrayList<SearchResult>();
>>>>>>>> +            return  
>>>>>>>> ((SearchActionBean)actionBean).getResults();
>>>>>>>>    }
>>>>>>>> -        return results;
>>>>>>>> +        return SearchActionBean.NO_RESULTS;
>>>>>>>> }
>>>>>>>>
>>>>>>>> /**
>>>>>>>>
>>>>>>>> Modified:
>>>>>>>>
>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>>>> SearchResultsSizeTag.java
>>>>>>>> URL:
>>>>>>>>
>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsSizeTag.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>>>>>
>>>>>>>>
>>>>>>>> === 
>>>>>>>> === 
>>>>>>>> === 
>>>>>>>> === 
>>>>>>>> === 
>>>>>>>> ===============================================================
>>>>>>>> ---
>>>>>>>>
>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>>>> SearchResultsSizeTag.java
>>>>>>>> (original)
>>>>>>>> +++
>>>>>>>>
>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>>>> SearchResultsSizeTag.java
>>>>>>>> Mon Jun  8 01:37:33 2009
>>>>>>>> @@ -22,8 +22,8 @@
>>>>>>>>
>>>>>>>> import java.io.IOException;
>>>>>>>> import java.util.Collection;
>>>>>>>> -import javax.servlet.jsp.PageContext;
>>>>>>>>
>>>>>>>> +import org.apache.wiki.action.SearchActionBean;
>>>>>>>> import org.apache.wiki.search.SearchResult;
>>>>>>>>
>>>>>>>> /**
>>>>>>>> @@ -37,17 +37,14 @@
>>>>>>>> {
>>>>>>>> private static final long serialVersionUID = 0L;
>>>>>>>>
>>>>>>>> -    @SuppressWarnings("unchecked")
>>>>>>>> public final int doWikiStartTag()
>>>>>>>>    throws IOException
>>>>>>>> {
>>>>>>>> -        Collection<SearchResult> list =
>>>>>>>> (Collection< 
>>>>>>>> SearchResult>)pageContext.getAttribute( "searchresults",
>>>>>>>> -
>>>>>>>> PageContext.REQUEST_SCOPE );
>>>>>>>> -        if( list != null )
>>>>>>>> +        if ( m_wikiActionBean != null && m_wikiActionBean  
>>>>>>>> instanceof
>>>>>>>> SearchActionBean )
>>>>>>>>    {
>>>>>>>> -            pageContext.getOut().print( list.size() );
>>>>>>>> +            Collection<SearchResult> results =
>>>>>>>> ((SearchActionBean)m_wikiActionBean).getResults();
>>>>>>>> +            pageContext.getOut().print( results.size() );
>>>>>>>>    }
>>>>>>>> -
>>>>>>>>    return SKIP_BODY;
>>>>>>>> }
>>>>>>>> }
>>>>>>>>
>>>>>>>> Modified:
>>>>>>>>
>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>>>> SearchResultsTag.java
>>>>>>>> URL:
>>>>>>>>
>>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsTag.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>>>>>
>>>>>>>>
>>>>>>>> === 
>>>>>>>> === 
>>>>>>>> === 
>>>>>>>> === 
>>>>>>>> === 
>>>>>>>> ===============================================================
>>>>>>>> ---
>>>>>>>>
>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>>>> SearchResultsTag.java
>>>>>>>> (original)
>>>>>>>> +++
>>>>>>>>
>>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>>>> SearchResultsTag.java
>>>>>>>> Mon Jun  8 01:37:33 2009
>>>>>>>> @@ -21,10 +21,10 @@
>>>>>>>> package org.apache.wiki.tags;
>>>>>>>>
>>>>>>>> import java.io.IOException;
>>>>>>>> -import java.util.Collection;
>>>>>>>> +
>>>>>>>> import javax.servlet.jsp.PageContext;
>>>>>>>>
>>>>>>>> -import org.apache.wiki.search.SearchResult;
>>>>>>>> +import org.apache.wiki.action.SearchActionBean;
>>>>>>>>
>>>>>>>> /**
>>>>>>>> *  Includes the body content, if there are any search results.
>>>>>>>> @@ -36,16 +36,16 @@
>>>>>>>> {
>>>>>>>> private static final long serialVersionUID = 0L;
>>>>>>>>
>>>>>>>> -    @SuppressWarnings("unchecked")
>>>>>>>> public final int doWikiStartTag()
>>>>>>>>    throws IOException
>>>>>>>> {
>>>>>>>> -        Collection<SearchResult> list =
>>>>>>>> (Collection< 
>>>>>>>> SearchResult>)pageContext.getAttribute( "searchresults",
>>>>>>>> -
>>>>>>>> PageContext.REQUEST_SCOPE );
>>>>>>>> -
>>>>>>>> -        if( list != null )
>>>>>>>> +        if ( m_wikiActionBean != null && m_wikiActionBean  
>>>>>>>> instanceof
>>>>>>>> SearchActionBean )
>>>>>>>>    {
>>>>>>>> -            return EVAL_BODY_INCLUDE;
>>>>>>>> +            boolean emptyQuery =
>>>>>>>> ((SearchActionBean)m_wikiActionBean).getQuery() == null;
>>>>>>>> +            if ( !emptyQuery )
>>>>>>>> +            {
>>>>>>>> +                return EVAL_BODY_INCLUDE;
>>>>>>>> +            }
>>>>>>>>    }
>>>>>>>>
>>>>>>>>    String message = (String)pageContext.getAttribute( "err",
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>
>>>
>
> mport org.apache.wiki.action.SearchActionBean;
>>>>>>>>
>>>>>>>> /**
>>>>>>>> *  Includes the body content, if there are any search results.
>>>>>>>> @@ -36,16 +36,16 @@
>>>>>>>> {
>>>>>>>> private static final long serialVersionUID = 0L;
>>>>>>>>
>>>>>>>> -    @SuppressWarnings("unchecked")
>>>>>>>> public final int doWikiStartTag()
>>>>>>>>    throws IOException
>>>>>>>> {
>>>>>>>> -        Collection<SearchResult> list =
>>>>>>>> (Collection< 
>>>>>>>> SearchResult>)pageContext.getAttribute( "searchresults",
>>>>>>>> -
>>>>>>>> PageContext.REQUEST_SCOPE );
>>>>>>>> -
>>>>>>>> -        if( list != null )
>>>>>>>> +        if ( m_wikiActionBean != null && m_wikiActionBean  
>>>>>>>> instanceof
>>>>>>>> SearchActionBean )
>>>>>>>>    {
>>>>>>>> -            return EVAL_BODY_INCLUDE;
>>>>>>>> +            boolean emptyQuery =
>>>>>>>> ((SearchActionBean)m_wikiActionBean).getQuery() == null;
>>>>>>>> +            if ( !emptyQuery )
>>>>>>>> +            {
>>>>>>>> +                return EVAL_BODY_INCLUDE;
>>>>>>>> +            }
>>>>>>>>    }
>>>>>>>>
>>>>>>>>    String message = (String)pageContext.getAttribute( "err",
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>
>>>
>

Re: svn commit: r782495 - in /incubator/jspwiki/trunk/src: WebContent/ WebContent/scripts/ WebContent/templates/default/ java/org/apache/wiki/ java/org/apache/wiki/action/ java/org/apache/wiki/tags/

Posted by Janne Jalkanen <ja...@ecyrd.com>.
Yup, saw them.  Still wondering if it would be neater to build an  
annotation for marking a bean handler method for JSON somehow. Or  
support jabsorb-like discovery of ActionBean methods.

Servlets do have one advantage though - Stripes supports only GET and  
POST, which it treats completely similarly. HEAD, DELETE, PUT, etc are  
not supported [which might be needed in a truly RESTful API]. Also,  
since Stripes insists on parsing POST before it gets to the  
ActionBean, in some instances you will need to bang it to its senses.

For example, if we still supported DAV, that could not be done with  
Stripes without extending the Stripes DispatcherServlet.  Or if we  
needed the actual POST body data in an ActionBean.

(Also, we still have XML-RPC servlets, which I wouldn't touch...)

/Janne

On 9 Jun 2009, at 23:15, Andrew Jaquith wrote:

> Janne, see my checked-in JSON notes in docs/ and also  
> SearchActionBean for an example. Simply stated, ActionBean AJAX  
> event methods need only return a JavaScriptResolution, the contents  
> of which can be retrieved client-side by eval().
>
> Yes, the idea is to talk to the 'beans directly -- no need to  
> "bridge" anything. A little creative @UrlBinding magic eliminates  
> the need for servlets too. See what I've done with AttachActionBean...
>
> Andrew
>
> On Jun 9, 2009, at 15:24, Janne Jalkanen <ja...@ecyrd.com>  
> wrote:
>
>>
>> That would be good so we can get rid of jabsorb, jsonrpc and the  
>> GlobalRPCBridge (which is amazingly huge, as documented by someone).
>>
>> I can probably do some hacking on the serverside over the weekend  
>> as well.
>>
>> /Janne
>>
>> On 9 Jun 2009, at 21:03, Dirk Frederickx wrote:
>>
>>> Janne, Andrew,
>>>
>>>
>>> Wiki.jsonrpc() is pretty much doing what you are  suggesting.
>>> It just needs an update not to work anymore with JsonRPC but with  
>>> hook-up
>>> with Stripes' approach to ajax.
>>>
>>> This shouldn't be to hard to figure out.
>>> I'll check this out over the weekend, unless anyone is moving  
>>> faster ;-)
>>>
>>>
>>> dirk
>>>
>>> On Mon, Jun 8, 2009 at 9:53 PM, Janne Jalkanen <janne.jalkanen@ecyrd.com 
>>> >wrote:
>>>
>>>>
>>>> Reminds me - the JS code used to call Ajax routines is disgustingly
>>>> loathsome and makes my eyes bleed and my stomach retch.  Can we  
>>>> upgrade to a
>>>> newer Mootools lib (1.2.2, I think) and switch to Request.JSON  
>>>> and create a
>>>> JSONFactory or an extension for creating our AJAX requests?
>>>>
>>>> Something like wiki.json( "Search", "ajaxSearch", { param1 :  
>>>> value1, ... },
>>>> callback(resultobj,resulttext) ); would be nice. This would  
>>>> construct the
>>>> URL to SearchActionBean, method ajaxSearch, with the given params.
>>>>
>>>> /Janne
>>>>
>>>> On 8 Jun 2009, at 21:52, Andrew Jaquith wrote:
>>>>
>>>> It will fix this one -- but only after we've hooked it up to the
>>>>> client JavaScript. Should not take long.
>>>>>
>>>>> On Mon, Jun 8, 2009 at 2:44 PM, Harry Metske<harry.metske@gmail.com 
>>>>> >
>>>>> wrote:
>>>>>
>>>>>> Andrew,
>>>>>>
>>>>>> should this patch have fixed
>>>>>> https://issues.apache.org/jira/browse/JSPWIKI-510 (only for 3.0  
>>>>>> of
>>>>>> course) ?
>>>>>>
>>>>>> Harry
>>>>>>
>>>>>> 2009/6/8 <aj...@apache.org>
>>>>>>
>>>>>>
>>>>>> Author: ajaquith
>>>>>>> Date: Mon Jun  8 01:37:33 2009
>>>>>>> New Revision: 782495
>>>>>>>
>>>>>>> URL: http://svn.apache.org/viewvc?rev=782495&view=rev
>>>>>>> Log:
>>>>>>> Search.jsp migrated to Stripes. SearchActionBean now provides  
>>>>>>> searching
>>>>>>> logic, including an ajaxSearch() method that filters results  
>>>>>>> correctly
>>>>>>> (this
>>>>>>> is not hooked up to the client JavaScript yet, but it should be
>>>>>>> straightforward to do). Still some i18n cleanup to do.
>>>>>>>
>>>>>>> Modified:
>>>>>>> incubator/jspwiki/trunk/src/WebContent/Search.jsp
>>>>>>> incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-common.js
>>>>>>>
>>>>>>> incubator/jspwiki/trunk/src/WebContent/templates/default/ 
>>>>>>> FindContent.jsp
>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ 
>>>>>>> WikiContext.java
>>>>>>>
>>>>>>>
>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/action/ 
>>>>>>> SearchActionBean.java
>>>>>>>
>>>>>>>
>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>>> IfNoSearchResultsTag.java
>>>>>>>
>>>>>>>
>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>>> SearchResultIteratorTag.java
>>>>>>>
>>>>>>>
>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>>> SearchResultsSizeTag.java
>>>>>>>
>>>>>>>
>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>>> SearchResultsTag.java
>>>>>>>
>>>>>>> Modified: incubator/jspwiki/trunk/src/WebContent/Search.jsp
>>>>>>> URL:
>>>>>>>
>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/WebContent/Search.jsp?rev=782495&r1=782494&r2=782495&view=diff
>>>>>>>
>>>>>>>
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> ================================================================
>>>>>>> --- incubator/jspwiki/trunk/src/WebContent/Search.jsp (original)
>>>>>>> +++ incubator/jspwiki/trunk/src/WebContent/Search.jsp Mon Jun  8
>>>>>>> 01:37:33
>>>>>>> 2009
>>>>>>> @@ -18,108 +18,12 @@
>>>>>>> specific language governing permissions and limitations
>>>>>>> under the License.
>>>>>>> --%>
>>>>>>> -<%@ page import="org.apache.wiki.log.Logger" %>
>>>>>>> -<%@ page import="org.apache.wiki.log.LoggerFactory" %>
>>>>>>> -<%@ page import="org.apache.wiki.*" %>
>>>>>>> -<%@ page import="org.apache.wiki.auth.*" %>
>>>>>>> -<%@ page import="org.apache.wiki.auth.permissions.*" %>
>>>>>>> -<%@ page import="java.util.*" %>
>>>>>>> +<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld"  
>>>>>>> prefix="s"
>>>>>>> %>
>>>>>>> <%@ page errorPage="/Error.jsp" %>
>>>>>>> -<%@ page import="org.apache.wiki.search.*" %>
>>>>>>> -<%@ taglib uri="http://jakarta.apache.org/jspwiki.tld"  
>>>>>>> prefix="wiki"
>>>>>>> %>
>>>>>>> -<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld"
>>>>>>> prefix="stripes" %>
>>>>>>> -<%@ page import="org.apache.wiki.util.TextUtil" %>
>>>>>>> -<%@ page import="org.apache.wiki.api.WikiPage" %>
>>>>>>> -<stripes:useActionBean
>>>>>>> beanclass="org.apache.wiki.action.SearchActionBean"
>>>>>>> event="find" id="wikiActionBean" />
>>>>>>> +<s:useActionBean  
>>>>>>> beanclass="org.apache.wiki.action.SearchActionBean"
>>>>>>> event="search" executeResolution="true" id="wikiActionBean" />
>>>>>>> +<s:layout-render name="${templates['DefaultLayout.jsp']}">
>>>>>>> +  <s:layout-component name="content">
>>>>>>> +      <jsp:include page="${templates['FindContent.jsp']}" />
>>>>>>> +  </s:layout-component>
>>>>>>> +</s:layout-render>
>>>>>>>
>>>>>>> -<%!
>>>>>>> -    Logger log = LoggerFactory.getLogger("JSPWikiSearch");
>>>>>>> -%>
>>>>>>> -
>>>>>>> -<%
>>>>>>> -    WikiEngine wiki =  
>>>>>>> WikiEngine.getInstance( getServletConfig() );
>>>>>>> -    // Create wiki context and check for authorization
>>>>>>> -    WikiContext wikiContext = wiki.createContext( request,
>>>>>>> WikiContext.FIND );
>>>>>>> -    String pagereq = wikiContext.getPage().getName();
>>>>>>> -
>>>>>>> -    // Get the search results
>>>>>>> -    Collection list = null;
>>>>>>> -    String query = request.getParameter( "query");
>>>>>>> -    String go    = request.getParameter("go");
>>>>>>> -
>>>>>>> -    if( query != null )
>>>>>>> -    {
>>>>>>> -        log.info("Searching for string "+query);
>>>>>>> -
>>>>>>> -        try
>>>>>>> -        {
>>>>>>> -            list = wiki.findPages( query );
>>>>>>> -
>>>>>>> -            //
>>>>>>> -            //  Filter down to only those that we actually  
>>>>>>> have a
>>>>>>> permission to view
>>>>>>> -            //
>>>>>>> -            AuthorizationManager mgr =  
>>>>>>> wiki.getAuthorizationManager();
>>>>>>> -
>>>>>>> -            ArrayList filteredList = new ArrayList();
>>>>>>> -
>>>>>>> -            for( Iterator i = list.iterator(); i.hasNext(); )
>>>>>>> -            {
>>>>>>> -                SearchResult r = (SearchResult)i.next();
>>>>>>> -
>>>>>>> -                WikiPage p = r.getPage();
>>>>>>> -
>>>>>>> -                PagePermission pp = new PagePermission( p,
>>>>>>> PagePermission.VIEW_ACTION );
>>>>>>> -
>>>>>>> -                try
>>>>>>> -                {
>>>>>>> -                    if( mgr.checkPermission(
>>>>>>> wikiContext.getWikiSession(),
>>>>>>> pp ) )
>>>>>>> -                    {
>>>>>>> -                        filteredList.add( r );
>>>>>>> -                    }
>>>>>>> -                }
>>>>>>> -                catch( Exception e ) { log.error( "Searching  
>>>>>>> for page
>>>>>>> "+p,
>>>>>>> e ); }
>>>>>>> -            }
>>>>>>> -
>>>>>>> -            pageContext.setAttribute( "searchresults",
>>>>>>> -                                      filteredList,
>>>>>>> -                                       
>>>>>>> PageContext.REQUEST_SCOPE );
>>>>>>> -        }
>>>>>>> -        catch( Exception e )
>>>>>>> -        {
>>>>>>> -             
>>>>>>> wikiContext.getWikiSession().addMessage( e.getMessage() );
>>>>>>> -        }
>>>>>>> -
>>>>>>> -        query = TextUtil.replaceEntities( query );
>>>>>>> -
>>>>>>> -        pageContext.setAttribute( "query",
>>>>>>> -                                  query,
>>>>>>> -                                  PageContext.REQUEST_SCOPE );
>>>>>>> -
>>>>>>> -        //
>>>>>>> -        //  Did the user click on "go"?
>>>>>>> -        //
>>>>>>> -        if( go != null )
>>>>>>> -        {
>>>>>>> -            if( list != null && list.size() > 0 )
>>>>>>> -            {
>>>>>>> -                SearchResult sr = (SearchResult)
>>>>>>> list.iterator().next();
>>>>>>> -
>>>>>>> -                WikiPage wikiPage = sr.getPage();
>>>>>>> -
>>>>>>> -                String url =  
>>>>>>> wikiContext.getViewURL( wikiPage.getName()
>>>>>>> );
>>>>>>> -
>>>>>>> -                response.sendRedirect( url );
>>>>>>> -
>>>>>>> -                return;
>>>>>>> -            }
>>>>>>> -        }
>>>>>>> -    }
>>>>>>> -
>>>>>>> -    // Set the content type and include the response content
>>>>>>> -    response.setContentType("text/html;
>>>>>>> charset="+wiki.getContentEncoding() );
>>>>>>> -    String contentPage = wiki.getTemplateManager().findJSP(
>>>>>>> pageContext,
>>>>>>> -
>>>>>>> wikiContext.getTemplate(),
>>>>>>> -
>>>>>>> "ViewTemplate.jsp" );
>>>>>>> -%><wiki:Include page="<%=contentPage%>" /><%
>>>>>>> -    log.debug("SEARCH COMPLETE");
>>>>>>> -%>
>>>>>>>
>>>>>>> Modified:
>>>>>>> incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-common.js
>>>>>>> URL:
>>>>>>>
>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-common.js?rev=782495&r1=782494&r2=782495&view=diff
>>>>>>>
>>>>>>>
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> ================================================================
>>>>>>> --- incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki- 
>>>>>>> common.js
>>>>>>> (original)
>>>>>>> +++ incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki- 
>>>>>>> common.js Mon
>>>>>>> Jun  8 01:37:33 2009
>>>>>>> @@ -931,9 +931,9 @@
>>>>>>>                    if (option.value == match) option.selected  
>>>>>>> = true;
>>>>>>>            });
>>>>>>>
>>>>>>> -               new Ajax(Wiki.TemplateUrl+'AJAXSearch.jsp', {
>>>>>>> -                       postBody: $ 
>>>>>>> ('searchform2').toQueryString(),
>>>>>>> -                       update: 'searchResult2',
>>>>>>> +               new Ajax(Wiki.BasePath+'Search.action', {
>>>>>>> +                       postBody:
>>>>>>> "ajaxSearch=&"+$('searchform2').toQueryString(),
>>>>>>> +                       update: 'searchResult2',
>>>>>>>                    method: 'post',
>>>>>>>                    onComplete: function() {
>>>>>>>                            $('spin').hide();
>>>>>>>
>>>>>>> Modified:
>>>>>>> incubator/jspwiki/trunk/src/WebContent/templates/default/ 
>>>>>>> FindContent.jsp
>>>>>>> URL:
>>>>>>>
>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/WebContent/templates/default/FindContent.jsp?rev=782495&r1=782494&r2=782495&view=diff
>>>>>>>
>>>>>>>
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> ================================================================
>>>>>>> ---
>>>>>>> incubator/jspwiki/trunk/src/WebContent/templates/default/ 
>>>>>>> FindContent.jsp
>>>>>>> (original)
>>>>>>> +++
>>>>>>> incubator/jspwiki/trunk/src/WebContent/templates/default/ 
>>>>>>> FindContent.jsp
>>>>>>> Mon
>>>>>>> Jun  8 01:37:33 2009
>>>>>>> @@ -27,24 +27,18 @@
>>>>>>> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
>>>>>>> <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"  
>>>>>>> %>
>>>>>>> <%@ page import="javax.servlet.jsp.jstl.fmt.*" %>
>>>>>>> -<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld"
>>>>>>> prefix="stripes" %>
>>>>>>> +<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld"  
>>>>>>> prefix="s"
>>>>>>> %>
>>>>>>>
>>>>>>> <wiki:TabbedSection>
>>>>>>> <wiki:Tab id="findcontent" titleKey="find.tab" accesskey="s">
>>>>>>>
>>>>>>> -<form action="<wiki:Link format='url' jsp='Search.jsp'/>"
>>>>>>> -       class="wikiform"
>>>>>>> -          id="searchform2"
>>>>>>> -         accept-charset="<wiki:ContentEncoding/>">
>>>>>>> -
>>>>>>> +<s:form beanclass="org.apache.wiki.action.SearchActionBean"
>>>>>>> class="wikiform"
>>>>>>> +    id="searchform2" acceptcharset="UTF-8">
>>>>>>> +
>>>>>>> <h4><fmt:message key="find.input" /></h4>
>>>>>>> <p>
>>>>>>> -    <input type="text"
>>>>>>> -           name="query" id="query2"
>>>>>>> -          value="<c:out value='${query}'/>"
>>>>>>> -           size="32" />
>>>>>>> -
>>>>>>> -    <input type="checkbox" name="details" id="details" <c:if
>>>>>>> test='${param.details == "on"}'>checked='checked'</c:if> />
>>>>>>> +    <s:text name="query" id="query2" size="32" />
>>>>>>> +    <s:checkbox name="details" id="details" />
>>>>>>> <fmt:message key="find.details" />
>>>>>>>
>>>>>>> <select name="scope" id="scope">
>>>>>>> @@ -55,16 +49,83 @@
>>>>>>>   <option value="attachment:" <c:if test='${param.scope eq
>>>>>>> "attachment:"}'>selected="selected"</c:if> ><fmt:message
>>>>>>> key='find.scope.attach' /></option>
>>>>>>> </select>
>>>>>>>
>>>>>>> -       <input type="submit" name="ok" id="ok"  
>>>>>>> value="<fmt:message
>>>>>>> key="find.submit.find" />" />
>>>>>>> -       <input type="submit" name="go" id="go"  
>>>>>>> value="<fmt:message
>>>>>>> key="find.submit.go" />" />
>>>>>>> -    <input type="hidden" name="start" id="start" value="0" />
>>>>>>> -    <input type="hidden" name="maxitems" id="maxitems"  
>>>>>>> value="20" />
>>>>>>> +    <s:submit name="search" id="ok" value="<fmt:message
>>>>>>> key='find.submit.find' />" />
>>>>>>> +    <s:submit name="go" id="go" value="<fmt:message
>>>>>>> key='find.submit.go'
>>>>>>> />" />
>>>>>>> +    <s:hidden name="start" id="start" value="0" />
>>>>>>> +    <s:hidden name="maxItems" id="maxitems" value="20" />
>>>>>>>
>>>>>>> <span id="spin" class="spin"
>>>>>>> style="position:absolute;display:none;"></span>
>>>>>>> </p>
>>>>>>> -</form>
>>>>>>> +</s:form>
>>>>>>> +
>>>>>>> +<div id="searchResult2">
>>>>>>> +  <wiki:SearchResults>
>>>>>>> +
>>>>>>> +    <h4><fmt:message  
>>>>>>> key="find.heading.results"><fmt:param><c:out
>>>>>>> value="${wikiActionBean.query}" /></fmt:param></fmt:message></ 
>>>>>>> h4>
>>>>>>> +    <p>
>>>>>>> +      <fmt:message key="find.externalsearch" />
>>>>>>> +      <a class="external" href="http://www.google.com/search? 
>>>>>>> q=<c:out
>>>>>>> value='${wikiActionBean.query}' />" title="Google Search '<c:out
>>>>>>> value='${wikiActionBean.query}' />'" target="_blank">Google</ 
>>>>>>> a><img
>>>>>>> class="outlink" src="images/out.png" alt="" />
>>>>>>> +      |
>>>>>>> +      <a class="external" href="
>>>>>>> http://en.wikipedia.org/wiki/Special:Search?search=<c:out
>>>>>>> value='${wikiActionBean.query}' />" title="Wikipedia Search  
>>>>>>> '<c:out
>>>>>>> value='${wikiActionBean.query}' />'"  
>>>>>>> target="_blank">Wikipedia</a><img
>>>>>>> class="outlink" src="images/out.png" alt="" />
>>>>>>> +    </p>
>>>>>>> +
>>>>>>> +    <wiki:SetPagination start="${wikiActionBean.start}"
>>>>>>> total="${wikiActionBean.resultsCount}" pagesize="20"  
>>>>>>> maxlinks="9"
>>>>>>> fmtkey="info.pagination" onclick="$('start').value=%s;
>>>>>>> SearchBox.runfullsearch();" />
>>>>>>> +
>>>>>>> +    <div class="graphBars">
>>>>>>> +      <div class="zebra-table">
>>>>>>> +        <table class="wikitable">
>>>>>>> +
>>>>>>> +          <tr>
>>>>>>> +             <th align="left"><fmt:message  
>>>>>>> key="find.results.page"
>>>>>>> /></th>
>>>>>>> +             <th align="left"><fmt:message  
>>>>>>> key="find.results.score"
>>>>>>> /></th>
>>>>>>> +          </tr>
>>>>>>> +
>>>>>>> +          <wiki:SearchResultIterator id="searchref"
>>>>>>> start="${wikiActionBean.start}" maxItems="$ 
>>>>>>> {wikiActionBean.maxItems}">
>>>>>>> +          <tr>
>>>>>>> +            <td><wiki:LinkTo><wiki:PageName/></wiki:LinkTo></ 
>>>>>>> td>
>>>>>>> +            <td><span class="gBar"><%= searchref.getScore()
>>>>>>> %></span></td>
>>>>>>> +          </tr>
>>>>>>> +
>>>>>>> +          <c:if test="${wikiActionBean.details == 'true'}">
>>>>>>> +  <%
>>>>>>> +            String[] contexts = searchref.getContexts();
>>>>>>> +            if( (contexts != null) && (contexts.length > 0) )
>>>>>>> +            {
>>>>>>> +  %>
>>>>>>> +          <tr class="odd">
>>>>>>> +            <td colspan="2">
>>>>>>> +              <div class="fragment">
>>>>>>> +  <%
>>>>>>> +              for (int i = 0; i < contexts.length; i++)
>>>>>>> +              {
>>>>>>> +  %>
>>>>>>> +                <%= (i > 0 ) ? "<span  
>>>>>>> class='fragment_ellipsis'> ...
>>>>>>> </span>" : ""  %>
>>>>>>> +                <%= contexts[i]  %>
>>>>>>> +  <%
>>>>>>> +              }
>>>>>>> +  %>
>>>>>>> +               </div>
>>>>>>> +             </td>
>>>>>>> +           </tr>
>>>>>>> +  <%
>>>>>>> +            }
>>>>>>> +  %>
>>>>>>> +          </c:if><%-- details --%>
>>>>>>> +        </wiki:SearchResultIterator>
>>>>>>> +
>>>>>>> +        <wiki:IfNoSearchResults>
>>>>>>> +          <tr>
>>>>>>> +            <td class="nosearchresult" colspan="2"><fmt:message
>>>>>>> key="find.noresults" /></td>
>>>>>>> +          </tr>
>>>>>>> +        </wiki:IfNoSearchResults>
>>>>>>> +
>>>>>>> +        </table>
>>>>>>> +      </div>
>>>>>>> +    </div>
>>>>>>> +    ${pagination}
>>>>>>>
>>>>>>> -<div id="searchResult2"><wiki:Include page="AJAXSearch.jsp" / 
>>>>>>> ></div>
>>>>>>> +  </wiki:SearchResults>
>>>>>>> +</div>
>>>>>>>
>>>>>>> </wiki:Tab>
>>>>>>>
>>>>>>>
>>>>>>> Modified:
>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/ 
>>>>>>> WikiContext.java
>>>>>>> URL:
>>>>>>>
>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiContext.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>>>>
>>>>>>>
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> ================================================================
>>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/ 
>>>>>>> WikiContext.java
>>>>>>> (original)
>>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/ 
>>>>>>> WikiContext.java
>>>>>>> Mon
>>>>>>> Jun  8 01:37:33 2009
>>>>>>> @@ -103,7 +103,7 @@
>>>>>>> public static final String    COMMENT  =  
>>>>>>> HandlerInfo.getHandlerInfo(
>>>>>>> EditActionBean.class, "comment" ).getRequestContext();
>>>>>>>
>>>>>>> /** User is searching for content. */
>>>>>>> -    public static final String    FIND     =
>>>>>>> HandlerInfo.getHandlerInfo(
>>>>>>> SearchActionBean.class, "find" ).getRequestContext();
>>>>>>> +    public static final String    FIND     =
>>>>>>> HandlerInfo.getHandlerInfo(
>>>>>>> SearchActionBean.class, "search" ).getRequestContext();
>>>>>>>
>>>>>>> /** User wishes to create a new group */
>>>>>>> public static final String    CREATE_GROUP =
>>>>>>> HandlerInfo.getHandlerInfo( GroupActionBean.class, "create"
>>>>>>> ).getRequestContext();
>>>>>>>
>>>>>>> Modified:
>>>>>>>
>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/action/ 
>>>>>>> SearchActionBean.java
>>>>>>> URL:
>>>>>>>
>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/action/SearchActionBean.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>>>>
>>>>>>>
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> ================================================================
>>>>>>> ---
>>>>>>>
>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/action/ 
>>>>>>> SearchActionBean.java
>>>>>>> (original)
>>>>>>> +++
>>>>>>>
>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/action/ 
>>>>>>> SearchActionBean.java
>>>>>>> Mon Jun  8 01:37:33 2009
>>>>>>> @@ -21,18 +21,191 @@
>>>>>>>
>>>>>>> package org.apache.wiki.action;
>>>>>>>
>>>>>>> -import org.apache.wiki.ui.stripes.WikiRequestContext;
>>>>>>> +import java.util.ArrayList;
>>>>>>> +import java.util.Collection;
>>>>>>> +import java.util.Collections;
>>>>>>> +import java.util.List;
>>>>>>>
>>>>>>> import net.sourceforge.stripes.action.*;
>>>>>>> +import net.sourceforge.stripes.ajax.JavaScriptResolution;
>>>>>>> +
>>>>>>> +import org.apache.wiki.WikiEngine;
>>>>>>> +import org.apache.wiki.api.WikiPage;
>>>>>>> +import org.apache.wiki.auth.AuthorizationManager;
>>>>>>> +import org.apache.wiki.auth.permissions.PagePermission;
>>>>>>> +import org.apache.wiki.log.Logger;
>>>>>>> +import org.apache.wiki.log.LoggerFactory;
>>>>>>> +import org.apache.wiki.search.SearchResult;
>>>>>>> +import org.apache.wiki.ui.stripes.WikiRequestContext;
>>>>>>>
>>>>>>> +/**
>>>>>>> + * Searches the WikiPage collection for a given wiki.
>>>>>>> + */
>>>>>>> @UrlBinding( "/Search.jsp" )
>>>>>>> public class SearchActionBean extends AbstractActionBean
>>>>>>> {
>>>>>>> +    private Logger log =  
>>>>>>> LoggerFactory.getLogger("JSPWikiSearch");
>>>>>>> +
>>>>>>> +    public static final Collection<SearchResult> NO_RESULTS =
>>>>>>> Collections.emptyList();
>>>>>>> +
>>>>>>> +    private Collection<SearchResult> m_results = NO_RESULTS;
>>>>>>> +
>>>>>>> +    private String m_query = null;
>>>>>>> +
>>>>>>> +    private int m_maxItems = 20;
>>>>>>> +
>>>>>>> +    private int m_start = 0;
>>>>>>> +
>>>>>>> +    private boolean m_details = false;
>>>>>>> +
>>>>>>> +    public boolean getDetails()
>>>>>>> +    {
>>>>>>> +        return m_details;
>>>>>>> +    }
>>>>>>> +
>>>>>>> +    /**
>>>>>>> +     * Sets the search results so that details for each  
>>>>>>> result are
>>>>>>> displayed.
>>>>>>> +     * @param details whether details should be displayed
>>>>>>> +     */
>>>>>>> +    public void setDetails( boolean details )
>>>>>>> +    {
>>>>>>> +        m_details = details;
>>>>>>> +    }
>>>>>>> +
>>>>>>> +    public int getMaxItems()
>>>>>>> +    {
>>>>>>> +        return m_maxItems;
>>>>>>> +    }
>>>>>>> +
>>>>>>> +    public void setMaxItems( int maxItems )
>>>>>>> +    {
>>>>>>> +        m_maxItems = maxItems;
>>>>>>> +    }
>>>>>>> +
>>>>>>> +    public int getStart()
>>>>>>> +    {
>>>>>>> +        return m_start;
>>>>>>> +    }
>>>>>>> +
>>>>>>> +    public void setStart( int start )
>>>>>>> +    {
>>>>>>> +        m_start = start;
>>>>>>> +    }
>>>>>>> +
>>>>>>> +    /**
>>>>>>> +     * Returns the query string for the search.
>>>>>>> +     *
>>>>>>> +     * @return the query string
>>>>>>> +     */
>>>>>>> +    public String getQuery()
>>>>>>> +    {
>>>>>>> +        return m_query;
>>>>>>> +    }
>>>>>>> +
>>>>>>> +    /**
>>>>>>> +     * Returns the results of the search.
>>>>>>> +     *
>>>>>>> +     * @return the results
>>>>>>> +     */
>>>>>>> +    public Collection<SearchResult> getResults()
>>>>>>> +    {
>>>>>>> +        return m_results;
>>>>>>> +    }
>>>>>>> +
>>>>>>> +    /**
>>>>>>> +     * Returns the number of items returned by the current  
>>>>>>> search.
>>>>>>> +     * @return the number of items
>>>>>>> +     */
>>>>>>> +    public int getResultsCount()
>>>>>>> +    {
>>>>>>> +        return m_results.size();
>>>>>>> +    }
>>>>>>> +
>>>>>>> +    /**
>>>>>>> +     * Performs a search and returns the results as a list.  
>>>>>>> For a given
>>>>>>> WikiPage to
>>>>>>> +     * be included in the results, the user must have  
>>>>>>> permission to
>>>>>>> view
>>>>>>> it.
>>>>>>> +     * If the underlying providers encounter an abnormal  
>>>>>>> IOException or
>>>>>>> other error,
>>>>>>> +     * it will be added to the ActionBeanContext's validation  
>>>>>>> messages
>>>>>>> collection.
>>>>>>> +     * @param query the query
>>>>>>> +     * @return the results
>>>>>>> +     */
>>>>>>> +    private List<SearchResult> doSearch( String query )
>>>>>>> +    {
>>>>>>> +        log.info("Searching with query '"+ query + "'.");
>>>>>>> +        WikiEngine engine = getContext().getEngine();
>>>>>>> +        AuthorizationManager mgr =  
>>>>>>> engine.getAuthorizationManager();
>>>>>>> +
>>>>>>> +        //
>>>>>>> +        //  Filter down to only those that we actually have a
>>>>>>> permission
>>>>>>> to view
>>>>>>> +        //
>>>>>>> +        List<SearchResult> filteredResults = new
>>>>>>> ArrayList<SearchResult>();
>>>>>>> +        try
>>>>>>> +        {
>>>>>>> +            List<SearchResult> results =  
>>>>>>> engine.findPages( query );
>>>>>>> +            for( SearchResult result : results )
>>>>>>> +            {
>>>>>>> +                WikiPage page = result.getPage();
>>>>>>> +                PagePermission permission = new  
>>>>>>> PagePermission( page,
>>>>>>> PagePermission.VIEW_ACTION );
>>>>>>> +                try
>>>>>>> +                {
>>>>>>> +                    if( mgr.checkPermission(
>>>>>>> getContext().getWikiSession(), permission ) )
>>>>>>> +                    {
>>>>>>> +                        filteredResults.add( result );
>>>>>>> +                    }
>>>>>>> +                }
>>>>>>> +                catch( Exception e ) { log.error( "Searching  
>>>>>>> for page "
>>>>>>> +
>>>>>>> page, e ); }
>>>>>>> +            }
>>>>>>> +        }
>>>>>>> +        catch( Exception e )
>>>>>>> +        {
>>>>>>> +            log.debug( "Could not search using query '" +  
>>>>>>> query + "'.",
>>>>>>> e
>>>>>>> );
>>>>>>> +            Message message = new  
>>>>>>> SimpleMessage( e.getMessage() );
>>>>>>> +            getContext().getMessages().add( message );
>>>>>>> +            e.printStackTrace();
>>>>>>> +        }
>>>>>>> +        return filteredResults;
>>>>>>> +    }
>>>>>>> +
>>>>>>> +    /**
>>>>>>> +     * Sets the query string for the search.
>>>>>>> +     *
>>>>>>> +     * @param query the query string
>>>>>>> +     */
>>>>>>> +    public void setQuery( String query )
>>>>>>> +    {
>>>>>>> +        m_query = query;
>>>>>>> +    }
>>>>>>> +
>>>>>>> +    /**
>>>>>>> +     * Searches the wiki using the query string set for this
>>>>>>> +     * ActionBean. Search results are made available to  
>>>>>>> callers via the
>>>>>>> +     * {@link #getResults()} method (and EL expression
>>>>>>> +     * <code>$wikiActionBean.results</code>).
>>>>>>> +     *
>>>>>>> +     * @return always returns a {@link ForwardResolution} to
>>>>>>> +     *         <code>/Search.jsp</code>.
>>>>>>> +     */
>>>>>>> @DefaultHandler
>>>>>>> -    @HandlesEvent( "find" )
>>>>>>> +    @HandlesEvent( "search" )
>>>>>>> @WikiRequestContext( "find" )
>>>>>>> -    public Resolution view()
>>>>>>> +    public Resolution search()
>>>>>>> {
>>>>>>> +        m_results = m_query == null ? NO_RESULTS :  
>>>>>>> doSearch( m_query );
>>>>>>>     return new ForwardResolution( "/Search.jsp" );
>>>>>>> }
>>>>>>> +
>>>>>>> +    /**
>>>>>>> +     * Using AJAX, searches a specified wiki space using the  
>>>>>>> query
>>>>>>> string
>>>>>>> set for this
>>>>>>> +     * ActionBean. Results are streamed back to the client as  
>>>>>>> an array
>>>>>>> of
>>>>>>> JSON-encoded
>>>>>>> +     * SearchResult objects.
>>>>>>> +     *
>>>>>>> +     * @return always returns a {@link JavaScriptResolution}  
>>>>>>> containing
>>>>>>> the
>>>>>>> +     * results; this may be a zero-length array
>>>>>>> +     */
>>>>>>> +    @HandlesEvent( "ajaxSearch" )
>>>>>>> +    public Resolution ajaxSearch()
>>>>>>> +    {
>>>>>>> +        m_results = m_query == null ? NO_RESULTS :  
>>>>>>> doSearch( m_query );
>>>>>>> +        return new JavaScriptResolution( m_results );
>>>>>>> +    }
>>>>>>> }
>>>>>>>
>>>>>>> Modified:
>>>>>>>
>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>>> IfNoSearchResultsTag.java
>>>>>>> URL:
>>>>>>>
>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IfNoSearchResultsTag.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>>>>
>>>>>>>
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> ================================================================
>>>>>>> ---
>>>>>>>
>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>>> IfNoSearchResultsTag.java
>>>>>>> (original)
>>>>>>> +++
>>>>>>>
>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>>> IfNoSearchResultsTag.java
>>>>>>> Mon Jun  8 01:37:33 2009
>>>>>>> @@ -22,8 +22,8 @@
>>>>>>>
>>>>>>> import java.io.IOException;
>>>>>>> import java.util.Collection;
>>>>>>> -import javax.servlet.jsp.PageContext;
>>>>>>>
>>>>>>> +import org.apache.wiki.action.SearchActionBean;
>>>>>>> import org.apache.wiki.search.SearchResult;
>>>>>>>
>>>>>>> /**
>>>>>>> @@ -36,17 +36,18 @@
>>>>>>> {
>>>>>>> private static final long serialVersionUID = 0L;
>>>>>>>
>>>>>>> -    @SuppressWarnings("unchecked")
>>>>>>> public final int doWikiStartTag()
>>>>>>>     throws IOException
>>>>>>> {
>>>>>>> -        Collection<SearchResult> list =
>>>>>>> (Collection 
>>>>>>> <SearchResult>)pageContext.getAttribute( "searchresults",
>>>>>>> -
>>>>>>> PageContext.REQUEST_SCOPE );
>>>>>>> -        if( list == null || list.size() == 0 )
>>>>>>> -        {
>>>>>>> -            return EVAL_BODY_INCLUDE;
>>>>>>> +        if ( m_wikiActionBean != null && m_wikiActionBean  
>>>>>>> instanceof
>>>>>>> SearchActionBean )
>>>>>>> +        {
>>>>>>> +            boolean emptyQuery =
>>>>>>> ((SearchActionBean)m_wikiActionBean).getQuery() == null;
>>>>>>> +            Collection<SearchResult> results =
>>>>>>> ((SearchActionBean)m_wikiActionBean).getResults();
>>>>>>> +            if ( emptyQuery || results.size() > 0 )
>>>>>>> +            {
>>>>>>> +                return SKIP_BODY;
>>>>>>> +            }
>>>>>>>     }
>>>>>>> -
>>>>>>> -        return SKIP_BODY;
>>>>>>> +        return EVAL_BODY_INCLUDE;
>>>>>>> }
>>>>>>> }
>>>>>>>
>>>>>>> Modified:
>>>>>>>
>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>>> SearchResultIteratorTag.java
>>>>>>> URL:
>>>>>>>
>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultIteratorTag.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>>>>
>>>>>>>
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> ================================================================
>>>>>>> ---
>>>>>>>
>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>>> SearchResultIteratorTag.java
>>>>>>> (original)
>>>>>>> +++
>>>>>>>
>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>>> SearchResultIteratorTag.java
>>>>>>> Mon Jun  8 01:37:33 2009
>>>>>>> @@ -20,12 +20,12 @@
>>>>>>> */
>>>>>>> package org.apache.wiki.tags;
>>>>>>>
>>>>>>> -import java.util.ArrayList;
>>>>>>> import java.util.Collection;
>>>>>>>
>>>>>>> -import javax.servlet.jsp.PageContext;
>>>>>>> -
>>>>>>> +import org.apache.wiki.action.SearchActionBean;
>>>>>>> +import org.apache.wiki.action.WikiActionBean;
>>>>>>> import org.apache.wiki.search.SearchResult;
>>>>>>> +import org.apache.wiki.ui.stripes.WikiInterceptor;
>>>>>>>
>>>>>>> /**
>>>>>>> * Iterator tag for the current search results, as identified  
>>>>>>> by a
>>>>>>> @@ -36,19 +36,17 @@
>>>>>>> private static final long serialVersionUID = 1L;
>>>>>>>
>>>>>>> /**
>>>>>>> -     * \ Returns the list of SearchResults to iterate over.
>>>>>>> +     * Returns the list of SearchResults to iterate over.
>>>>>>>  */
>>>>>>> @Override
>>>>>>> -    @SuppressWarnings( "unchecked" )
>>>>>>> protected Collection<SearchResult> initItems()
>>>>>>> {
>>>>>>> -        Collection<SearchResult> results =  
>>>>>>> (Collection<SearchResult>)
>>>>>>> pageContext.getAttribute( "searchresults",
>>>>>>> -
>>>>>>>                  PageContext.REQUEST_SCOPE );
>>>>>>> -        if( results == null )
>>>>>>> +        WikiActionBean actionBean =  
>>>>>>> WikiInterceptor.findActionBean(
>>>>>>> pageContext );
>>>>>>> +        if ( actionBean != null && actionBean instanceof
>>>>>>> SearchActionBean
>>>>>>> )
>>>>>>>     {
>>>>>>> -            return new ArrayList<SearchResult>();
>>>>>>> +            return ((SearchActionBean)actionBean).getResults();
>>>>>>>     }
>>>>>>> -        return results;
>>>>>>> +        return SearchActionBean.NO_RESULTS;
>>>>>>> }
>>>>>>>
>>>>>>> /**
>>>>>>>
>>>>>>> Modified:
>>>>>>>
>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>>> SearchResultsSizeTag.java
>>>>>>> URL:
>>>>>>>
>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsSizeTag.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>>>>
>>>>>>>
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> ================================================================
>>>>>>> ---
>>>>>>>
>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>>> SearchResultsSizeTag.java
>>>>>>> (original)
>>>>>>> +++
>>>>>>>
>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>>> SearchResultsSizeTag.java
>>>>>>> Mon Jun  8 01:37:33 2009
>>>>>>> @@ -22,8 +22,8 @@
>>>>>>>
>>>>>>> import java.io.IOException;
>>>>>>> import java.util.Collection;
>>>>>>> -import javax.servlet.jsp.PageContext;
>>>>>>>
>>>>>>> +import org.apache.wiki.action.SearchActionBean;
>>>>>>> import org.apache.wiki.search.SearchResult;
>>>>>>>
>>>>>>> /**
>>>>>>> @@ -37,17 +37,14 @@
>>>>>>> {
>>>>>>> private static final long serialVersionUID = 0L;
>>>>>>>
>>>>>>> -    @SuppressWarnings("unchecked")
>>>>>>> public final int doWikiStartTag()
>>>>>>>     throws IOException
>>>>>>> {
>>>>>>> -        Collection<SearchResult> list =
>>>>>>> (Collection 
>>>>>>> <SearchResult>)pageContext.getAttribute( "searchresults",
>>>>>>> -
>>>>>>> PageContext.REQUEST_SCOPE );
>>>>>>> -        if( list != null )
>>>>>>> +        if ( m_wikiActionBean != null && m_wikiActionBean  
>>>>>>> instanceof
>>>>>>> SearchActionBean )
>>>>>>>     {
>>>>>>> -            pageContext.getOut().print( list.size() );
>>>>>>> +            Collection<SearchResult> results =
>>>>>>> ((SearchActionBean)m_wikiActionBean).getResults();
>>>>>>> +            pageContext.getOut().print( results.size() );
>>>>>>>     }
>>>>>>> -
>>>>>>>     return SKIP_BODY;
>>>>>>> }
>>>>>>> }
>>>>>>>
>>>>>>> Modified:
>>>>>>>
>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>>> SearchResultsTag.java
>>>>>>> URL:
>>>>>>>
>>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsTag.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>>>>
>>>>>>>
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> = 
>>>>>>> ================================================================
>>>>>>> ---
>>>>>>>
>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>>> SearchResultsTag.java
>>>>>>> (original)
>>>>>>> +++
>>>>>>>
>>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>>> SearchResultsTag.java
>>>>>>> Mon Jun  8 01:37:33 2009
>>>>>>> @@ -21,10 +21,10 @@
>>>>>>> package org.apache.wiki.tags;
>>>>>>>
>>>>>>> import java.io.IOException;
>>>>>>> -import java.util.Collection;
>>>>>>> +
>>>>>>> import javax.servlet.jsp.PageContext;
>>>>>>>
>>>>>>> -import org.apache.wiki.search.SearchResult;
>>>>>>> +import org.apache.wiki.action.SearchActionBean;
>>>>>>>
>>>>>>> /**
>>>>>>> *  Includes the body content, if there are any search results.
>>>>>>> @@ -36,16 +36,16 @@
>>>>>>> {
>>>>>>> private static final long serialVersionUID = 0L;
>>>>>>>
>>>>>>> -    @SuppressWarnings("unchecked")
>>>>>>> public final int doWikiStartTag()
>>>>>>>     throws IOException
>>>>>>> {
>>>>>>> -        Collection<SearchResult> list =
>>>>>>> (Collection 
>>>>>>> <SearchResult>)pageContext.getAttribute( "searchresults",
>>>>>>> -
>>>>>>> PageContext.REQUEST_SCOPE );
>>>>>>> -
>>>>>>> -        if( list != null )
>>>>>>> +        if ( m_wikiActionBean != null && m_wikiActionBean  
>>>>>>> instanceof
>>>>>>> SearchActionBean )
>>>>>>>     {
>>>>>>> -            return EVAL_BODY_INCLUDE;
>>>>>>> +            boolean emptyQuery =
>>>>>>> ((SearchActionBean)m_wikiActionBean).getQuery() == null;
>>>>>>> +            if ( !emptyQuery )
>>>>>>> +            {
>>>>>>> +                return EVAL_BODY_INCLUDE;
>>>>>>> +            }
>>>>>>>     }
>>>>>>>
>>>>>>>     String message = (String)pageContext.getAttribute( "err",
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>
>>


Re: svn commit: r782495 - in /incubator/jspwiki/trunk/src: WebContent/ WebContent/scripts/ WebContent/templates/default/ java/org/apache/wiki/ java/org/apache/wiki/action/ java/org/apache/wiki/tags/

Posted by Andrew Jaquith <an...@gmail.com>.
Janne, see my checked-in JSON notes in docs/ and also SearchActionBean  
for an example. Simply stated, ActionBean AJAX event methods need only  
return a JavaScriptResolution, the contents of which can be retrieved  
client-side by eval().

Yes, the idea is to talk to the 'beans directly -- no need to "bridge"  
anything. A little creative @UrlBinding magic eliminates the need for  
servlets too. See what I've done with AttachActionBean...

Andrew

On Jun 9, 2009, at 15:24, Janne Jalkanen <ja...@ecyrd.com>  
wrote:

>
> That would be good so we can get rid of jabsorb, jsonrpc and the  
> GlobalRPCBridge (which is amazingly huge, as documented by someone).
>
> I can probably do some hacking on the serverside over the weekend as  
> well.
>
> /Janne
>
> On 9 Jun 2009, at 21:03, Dirk Frederickx wrote:
>
>> Janne, Andrew,
>>
>>
>> Wiki.jsonrpc() is pretty much doing what you are  suggesting.
>> It just needs an update not to work anymore with JsonRPC but with  
>> hook-up
>> with Stripes' approach to ajax.
>>
>> This shouldn't be to hard to figure out.
>> I'll check this out over the weekend, unless anyone is moving  
>> faster ;-)
>>
>>
>> dirk
>>
>> On Mon, Jun 8, 2009 at 9:53 PM, Janne Jalkanen <janne.jalkanen@ecyrd.com 
>> >wrote:
>>
>>>
>>> Reminds me - the JS code used to call Ajax routines is disgustingly
>>> loathsome and makes my eyes bleed and my stomach retch.  Can we  
>>> upgrade to a
>>> newer Mootools lib (1.2.2, I think) and switch to Request.JSON and  
>>> create a
>>> JSONFactory or an extension for creating our AJAX requests?
>>>
>>> Something like wiki.json( "Search", "ajaxSearch", { param1 :  
>>> value1, ... },
>>> callback(resultobj,resulttext) ); would be nice. This would  
>>> construct the
>>> URL to SearchActionBean, method ajaxSearch, with the given params.
>>>
>>> /Janne
>>>
>>> On 8 Jun 2009, at 21:52, Andrew Jaquith wrote:
>>>
>>> It will fix this one -- but only after we've hooked it up to the
>>>> client JavaScript. Should not take long.
>>>>
>>>> On Mon, Jun 8, 2009 at 2:44 PM, Harry  
>>>> Metske<ha...@gmail.com>
>>>> wrote:
>>>>
>>>>> Andrew,
>>>>>
>>>>> should this patch have fixed
>>>>> https://issues.apache.org/jira/browse/JSPWIKI-510 (only for 3.0 of
>>>>> course) ?
>>>>>
>>>>> Harry
>>>>>
>>>>> 2009/6/8 <aj...@apache.org>
>>>>>
>>>>>
>>>>> Author: ajaquith
>>>>>> Date: Mon Jun  8 01:37:33 2009
>>>>>> New Revision: 782495
>>>>>>
>>>>>> URL: http://svn.apache.org/viewvc?rev=782495&view=rev
>>>>>> Log:
>>>>>> Search.jsp migrated to Stripes. SearchActionBean now provides  
>>>>>> searching
>>>>>> logic, including an ajaxSearch() method that filters results  
>>>>>> correctly
>>>>>> (this
>>>>>> is not hooked up to the client JavaScript yet, but it should be
>>>>>> straightforward to do). Still some i18n cleanup to do.
>>>>>>
>>>>>> Modified:
>>>>>> incubator/jspwiki/trunk/src/WebContent/Search.jsp
>>>>>> incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-common.js
>>>>>>
>>>>>> incubator/jspwiki/trunk/src/WebContent/templates/default/ 
>>>>>> FindContent.jsp
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiContext.java
>>>>>>
>>>>>>
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/action/ 
>>>>>> SearchActionBean.java
>>>>>>
>>>>>>
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>> IfNoSearchResultsTag.java
>>>>>>
>>>>>>
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>> SearchResultIteratorTag.java
>>>>>>
>>>>>>
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>> SearchResultsSizeTag.java
>>>>>>
>>>>>>
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>> SearchResultsTag.java
>>>>>>
>>>>>> Modified: incubator/jspwiki/trunk/src/WebContent/Search.jsp
>>>>>> URL:
>>>>>>
>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/WebContent/Search.jsp?rev=782495&r1=782494&r2=782495&view=diff
>>>>>>
>>>>>>
>>>>>> === 
>>>>>> === 
>>>>>> === 
>>>>>> === 
>>>>>> === 
>>>>>> ===============================================================
>>>>>> --- incubator/jspwiki/trunk/src/WebContent/Search.jsp (original)
>>>>>> +++ incubator/jspwiki/trunk/src/WebContent/Search.jsp Mon Jun  8
>>>>>> 01:37:33
>>>>>> 2009
>>>>>> @@ -18,108 +18,12 @@
>>>>>>  specific language governing permissions and limitations
>>>>>>  under the License.
>>>>>> --%>
>>>>>> -<%@ page import="org.apache.wiki.log.Logger" %>
>>>>>> -<%@ page import="org.apache.wiki.log.LoggerFactory" %>
>>>>>> -<%@ page import="org.apache.wiki.*" %>
>>>>>> -<%@ page import="org.apache.wiki.auth.*" %>
>>>>>> -<%@ page import="org.apache.wiki.auth.permissions.*" %>
>>>>>> -<%@ page import="java.util.*" %>
>>>>>> +<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld"  
>>>>>> prefix="s"
>>>>>> %>
>>>>>> <%@ page errorPage="/Error.jsp" %>
>>>>>> -<%@ page import="org.apache.wiki.search.*" %>
>>>>>> -<%@ taglib uri="http://jakarta.apache.org/jspwiki.tld"  
>>>>>> prefix="wiki"
>>>>>> %>
>>>>>> -<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld"
>>>>>> prefix="stripes" %>
>>>>>> -<%@ page import="org.apache.wiki.util.TextUtil" %>
>>>>>> -<%@ page import="org.apache.wiki.api.WikiPage" %>
>>>>>> -<stripes:useActionBean
>>>>>> beanclass="org.apache.wiki.action.SearchActionBean"
>>>>>> event="find" id="wikiActionBean" />
>>>>>> +<s:useActionBean  
>>>>>> beanclass="org.apache.wiki.action.SearchActionBean"
>>>>>> event="search" executeResolution="true" id="wikiActionBean" />
>>>>>> +<s:layout-render name="${templates['DefaultLayout.jsp']}">
>>>>>> +  <s:layout-component name="content">
>>>>>> +      <jsp:include page="${templates['FindContent.jsp']}" />
>>>>>> +  </s:layout-component>
>>>>>> +</s:layout-render>
>>>>>>
>>>>>> -<%!
>>>>>> -    Logger log = LoggerFactory.getLogger("JSPWikiSearch");
>>>>>> -%>
>>>>>> -
>>>>>> -<%
>>>>>> -    WikiEngine wiki =  
>>>>>> WikiEngine.getInstance( getServletConfig() );
>>>>>> -    // Create wiki context and check for authorization
>>>>>> -    WikiContext wikiContext = wiki.createContext( request,
>>>>>> WikiContext.FIND );
>>>>>> -    String pagereq = wikiContext.getPage().getName();
>>>>>> -
>>>>>> -    // Get the search results
>>>>>> -    Collection list = null;
>>>>>> -    String query = request.getParameter( "query");
>>>>>> -    String go    = request.getParameter("go");
>>>>>> -
>>>>>> -    if( query != null )
>>>>>> -    {
>>>>>> -        log.info("Searching for string "+query);
>>>>>> -
>>>>>> -        try
>>>>>> -        {
>>>>>> -            list = wiki.findPages( query );
>>>>>> -
>>>>>> -            //
>>>>>> -            //  Filter down to only those that we actually  
>>>>>> have a
>>>>>> permission to view
>>>>>> -            //
>>>>>> -            AuthorizationManager mgr =  
>>>>>> wiki.getAuthorizationManager();
>>>>>> -
>>>>>> -            ArrayList filteredList = new ArrayList();
>>>>>> -
>>>>>> -            for( Iterator i = list.iterator(); i.hasNext(); )
>>>>>> -            {
>>>>>> -                SearchResult r = (SearchResult)i.next();
>>>>>> -
>>>>>> -                WikiPage p = r.getPage();
>>>>>> -
>>>>>> -                PagePermission pp = new PagePermission( p,
>>>>>> PagePermission.VIEW_ACTION );
>>>>>> -
>>>>>> -                try
>>>>>> -                {
>>>>>> -                    if( mgr.checkPermission(
>>>>>> wikiContext.getWikiSession(),
>>>>>> pp ) )
>>>>>> -                    {
>>>>>> -                        filteredList.add( r );
>>>>>> -                    }
>>>>>> -                }
>>>>>> -                catch( Exception e ) { log.error( "Searching  
>>>>>> for page
>>>>>> "+p,
>>>>>> e ); }
>>>>>> -            }
>>>>>> -
>>>>>> -            pageContext.setAttribute( "searchresults",
>>>>>> -                                      filteredList,
>>>>>> -                                       
>>>>>> PageContext.REQUEST_SCOPE );
>>>>>> -        }
>>>>>> -        catch( Exception e )
>>>>>> -        {
>>>>>> -             
>>>>>> wikiContext.getWikiSession().addMessage( e.getMessage() );
>>>>>> -        }
>>>>>> -
>>>>>> -        query = TextUtil.replaceEntities( query );
>>>>>> -
>>>>>> -        pageContext.setAttribute( "query",
>>>>>> -                                  query,
>>>>>> -                                  PageContext.REQUEST_SCOPE );
>>>>>> -
>>>>>> -        //
>>>>>> -        //  Did the user click on "go"?
>>>>>> -        //
>>>>>> -        if( go != null )
>>>>>> -        {
>>>>>> -            if( list != null && list.size() > 0 )
>>>>>> -            {
>>>>>> -                SearchResult sr = (SearchResult)
>>>>>> list.iterator().next();
>>>>>> -
>>>>>> -                WikiPage wikiPage = sr.getPage();
>>>>>> -
>>>>>> -                String url =  
>>>>>> wikiContext.getViewURL( wikiPage.getName()
>>>>>> );
>>>>>> -
>>>>>> -                response.sendRedirect( url );
>>>>>> -
>>>>>> -                return;
>>>>>> -            }
>>>>>> -        }
>>>>>> -    }
>>>>>> -
>>>>>> -    // Set the content type and include the response content
>>>>>> -    response.setContentType("text/html;
>>>>>> charset="+wiki.getContentEncoding() );
>>>>>> -    String contentPage = wiki.getTemplateManager().findJSP(
>>>>>> pageContext,
>>>>>> -
>>>>>> wikiContext.getTemplate(),
>>>>>> -
>>>>>> "ViewTemplate.jsp" );
>>>>>> -%><wiki:Include page="<%=contentPage%>" /><%
>>>>>> -    log.debug("SEARCH COMPLETE");
>>>>>> -%>
>>>>>>
>>>>>> Modified:
>>>>>> incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-common.js
>>>>>> URL:
>>>>>>
>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-common.js?rev=782495&r1=782494&r2=782495&view=diff
>>>>>>
>>>>>>
>>>>>> === 
>>>>>> === 
>>>>>> === 
>>>>>> === 
>>>>>> === 
>>>>>> ===============================================================
>>>>>> --- incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki- 
>>>>>> common.js
>>>>>> (original)
>>>>>> +++ incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki- 
>>>>>> common.js Mon
>>>>>> Jun  8 01:37:33 2009
>>>>>> @@ -931,9 +931,9 @@
>>>>>>                     if (option.value == match) option.selected  
>>>>>> = true;
>>>>>>             });
>>>>>>
>>>>>> -               new Ajax(Wiki.TemplateUrl+'AJAXSearch.jsp', {
>>>>>> -                       postBody: $ 
>>>>>> ('searchform2').toQueryString(),
>>>>>> -                       update: 'searchResult2',
>>>>>> +               new Ajax(Wiki.BasePath+'Search.action', {
>>>>>> +                       postBody:
>>>>>> "ajaxSearch=&"+$('searchform2').toQueryString(),
>>>>>> +                       update: 'searchResult2',
>>>>>>                     method: 'post',
>>>>>>                     onComplete: function() {
>>>>>>                             $('spin').hide();
>>>>>>
>>>>>> Modified:
>>>>>> incubator/jspwiki/trunk/src/WebContent/templates/default/ 
>>>>>> FindContent.jsp
>>>>>> URL:
>>>>>>
>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/WebContent/templates/default/FindContent.jsp?rev=782495&r1=782494&r2=782495&view=diff
>>>>>>
>>>>>>
>>>>>> === 
>>>>>> === 
>>>>>> === 
>>>>>> === 
>>>>>> === 
>>>>>> ===============================================================
>>>>>> ---
>>>>>> incubator/jspwiki/trunk/src/WebContent/templates/default/ 
>>>>>> FindContent.jsp
>>>>>> (original)
>>>>>> +++
>>>>>> incubator/jspwiki/trunk/src/WebContent/templates/default/ 
>>>>>> FindContent.jsp
>>>>>> Mon
>>>>>> Jun  8 01:37:33 2009
>>>>>> @@ -27,24 +27,18 @@
>>>>>> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
>>>>>> <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
>>>>>> <%@ page import="javax.servlet.jsp.jstl.fmt.*" %>
>>>>>> -<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld"
>>>>>> prefix="stripes" %>
>>>>>> +<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld"  
>>>>>> prefix="s"
>>>>>> %>
>>>>>>
>>>>>> <wiki:TabbedSection>
>>>>>> <wiki:Tab id="findcontent" titleKey="find.tab" accesskey="s">
>>>>>>
>>>>>> -<form action="<wiki:Link format='url' jsp='Search.jsp'/>"
>>>>>> -       class="wikiform"
>>>>>> -          id="searchform2"
>>>>>> -         accept-charset="<wiki:ContentEncoding/>">
>>>>>> -
>>>>>> +<s:form beanclass="org.apache.wiki.action.SearchActionBean"
>>>>>> class="wikiform"
>>>>>> +    id="searchform2" acceptcharset="UTF-8">
>>>>>> +
>>>>>> <h4><fmt:message key="find.input" /></h4>
>>>>>> <p>
>>>>>> -    <input type="text"
>>>>>> -           name="query" id="query2"
>>>>>> -          value="<c:out value='${query}'/>"
>>>>>> -           size="32" />
>>>>>> -
>>>>>> -    <input type="checkbox" name="details" id="details" <c:if
>>>>>> test='${param.details == "on"}'>checked='checked'</c:if> />
>>>>>> +    <s:text name="query" id="query2" size="32" />
>>>>>> +    <s:checkbox name="details" id="details" />
>>>>>>  <fmt:message key="find.details" />
>>>>>>
>>>>>>  <select name="scope" id="scope">
>>>>>> @@ -55,16 +49,83 @@
>>>>>>    <option value="attachment:" <c:if test='${param.scope eq
>>>>>> "attachment:"}'>selected="selected"</c:if> ><fmt:message
>>>>>> key='find.scope.attach' /></option>
>>>>>>  </select>
>>>>>>
>>>>>> -       <input type="submit" name="ok" id="ok"  
>>>>>> value="<fmt:message
>>>>>> key="find.submit.find" />" />
>>>>>> -       <input type="submit" name="go" id="go"  
>>>>>> value="<fmt:message
>>>>>> key="find.submit.go" />" />
>>>>>> -    <input type="hidden" name="start" id="start" value="0" />
>>>>>> -    <input type="hidden" name="maxitems" id="maxitems"  
>>>>>> value="20" />
>>>>>> +    <s:submit name="search" id="ok" value="<fmt:message
>>>>>> key='find.submit.find' />" />
>>>>>> +    <s:submit name="go" id="go" value="<fmt:message
>>>>>> key='find.submit.go'
>>>>>> />" />
>>>>>> +    <s:hidden name="start" id="start" value="0" />
>>>>>> +    <s:hidden name="maxItems" id="maxitems" value="20" />
>>>>>>
>>>>>>  <span id="spin" class="spin"
>>>>>> style="position:absolute;display:none;"></span>
>>>>>> </p>
>>>>>> -</form>
>>>>>> +</s:form>
>>>>>> +
>>>>>> +<div id="searchResult2">
>>>>>> +  <wiki:SearchResults>
>>>>>> +
>>>>>> +    <h4><fmt:message  
>>>>>> key="find.heading.results"><fmt:param><c:out
>>>>>> value="${wikiActionBean.query}" /></fmt:param></fmt:message></h4>
>>>>>> +    <p>
>>>>>> +      <fmt:message key="find.externalsearch" />
>>>>>> +      <a class="external" href="http://www.google.com/search? 
>>>>>> q=<c:out
>>>>>> value='${wikiActionBean.query}' />" title="Google Search '<c:out
>>>>>> value='${wikiActionBean.query}' />'" target="_blank">Google</ 
>>>>>> a><img
>>>>>> class="outlink" src="images/out.png" alt="" />
>>>>>> +      |
>>>>>> +      <a class="external" href="
>>>>>> http://en.wikipedia.org/wiki/Special:Search?search=<c:out
>>>>>> value='${wikiActionBean.query}' />" title="Wikipedia Search  
>>>>>> '<c:out
>>>>>> value='${wikiActionBean.query}' />'" target="_blank">Wikipedia</ 
>>>>>> a><img
>>>>>> class="outlink" src="images/out.png" alt="" />
>>>>>> +    </p>
>>>>>> +
>>>>>> +    <wiki:SetPagination start="${wikiActionBean.start}"
>>>>>> total="${wikiActionBean.resultsCount}" pagesize="20" maxlinks="9"
>>>>>> fmtkey="info.pagination" onclick="$('start').value=%s;
>>>>>> SearchBox.runfullsearch();" />
>>>>>> +
>>>>>> +    <div class="graphBars">
>>>>>> +      <div class="zebra-table">
>>>>>> +        <table class="wikitable">
>>>>>> +
>>>>>> +          <tr>
>>>>>> +             <th align="left"><fmt:message  
>>>>>> key="find.results.page"
>>>>>> /></th>
>>>>>> +             <th align="left"><fmt:message  
>>>>>> key="find.results.score"
>>>>>> /></th>
>>>>>> +          </tr>
>>>>>> +
>>>>>> +          <wiki:SearchResultIterator id="searchref"
>>>>>> start="${wikiActionBean.start}" maxItems="$ 
>>>>>> {wikiActionBean.maxItems}">
>>>>>> +          <tr>
>>>>>> +            <td><wiki:LinkTo><wiki:PageName/></wiki:LinkTo></td>
>>>>>> +            <td><span class="gBar"><%= searchref.getScore()
>>>>>> %></span></td>
>>>>>> +          </tr>
>>>>>> +
>>>>>> +          <c:if test="${wikiActionBean.details == 'true'}">
>>>>>> +  <%
>>>>>> +            String[] contexts = searchref.getContexts();
>>>>>> +            if( (contexts != null) && (contexts.length > 0) )
>>>>>> +            {
>>>>>> +  %>
>>>>>> +          <tr class="odd">
>>>>>> +            <td colspan="2">
>>>>>> +              <div class="fragment">
>>>>>> +  <%
>>>>>> +              for (int i = 0; i < contexts.length; i++)
>>>>>> +              {
>>>>>> +  %>
>>>>>> +                <%= (i > 0 ) ? "<span  
>>>>>> class='fragment_ellipsis'> ...
>>>>>> </span>" : ""  %>
>>>>>> +                <%= contexts[i]  %>
>>>>>> +  <%
>>>>>> +              }
>>>>>> +  %>
>>>>>> +               </div>
>>>>>> +             </td>
>>>>>> +           </tr>
>>>>>> +  <%
>>>>>> +            }
>>>>>> +  %>
>>>>>> +          </c:if><%-- details --%>
>>>>>> +        </wiki:SearchResultIterator>
>>>>>> +
>>>>>> +        <wiki:IfNoSearchResults>
>>>>>> +          <tr>
>>>>>> +            <td class="nosearchresult" colspan="2"><fmt:message
>>>>>> key="find.noresults" /></td>
>>>>>> +          </tr>
>>>>>> +        </wiki:IfNoSearchResults>
>>>>>> +
>>>>>> +        </table>
>>>>>> +      </div>
>>>>>> +    </div>
>>>>>> +    ${pagination}
>>>>>>
>>>>>> -<div id="searchResult2"><wiki:Include page="AJAXSearch.jsp" / 
>>>>>> ></div>
>>>>>> +  </wiki:SearchResults>
>>>>>> +</div>
>>>>>>
>>>>>> </wiki:Tab>
>>>>>>
>>>>>>
>>>>>> Modified:
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiContext.java
>>>>>> URL:
>>>>>>
>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiContext.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>>>
>>>>>>
>>>>>> === 
>>>>>> === 
>>>>>> === 
>>>>>> === 
>>>>>> === 
>>>>>> ===============================================================
>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/ 
>>>>>> WikiContext.java
>>>>>> (original)
>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/ 
>>>>>> WikiContext.java
>>>>>> Mon
>>>>>> Jun  8 01:37:33 2009
>>>>>> @@ -103,7 +103,7 @@
>>>>>>  public static final String    COMMENT  =  
>>>>>> HandlerInfo.getHandlerInfo(
>>>>>> EditActionBean.class, "comment" ).getRequestContext();
>>>>>>
>>>>>>  /** User is searching for content. */
>>>>>> -    public static final String    FIND     =
>>>>>> HandlerInfo.getHandlerInfo(
>>>>>> SearchActionBean.class, "find" ).getRequestContext();
>>>>>> +    public static final String    FIND     =
>>>>>> HandlerInfo.getHandlerInfo(
>>>>>> SearchActionBean.class, "search" ).getRequestContext();
>>>>>>
>>>>>>  /** User wishes to create a new group */
>>>>>>  public static final String    CREATE_GROUP =
>>>>>> HandlerInfo.getHandlerInfo( GroupActionBean.class, "create"
>>>>>> ).getRequestContext();
>>>>>>
>>>>>> Modified:
>>>>>>
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/action/ 
>>>>>> SearchActionBean.java
>>>>>> URL:
>>>>>>
>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/action/SearchActionBean.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>>>
>>>>>>
>>>>>> === 
>>>>>> === 
>>>>>> === 
>>>>>> === 
>>>>>> === 
>>>>>> ===============================================================
>>>>>> ---
>>>>>>
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/action/ 
>>>>>> SearchActionBean.java
>>>>>> (original)
>>>>>> +++
>>>>>>
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/action/ 
>>>>>> SearchActionBean.java
>>>>>> Mon Jun  8 01:37:33 2009
>>>>>> @@ -21,18 +21,191 @@
>>>>>>
>>>>>> package org.apache.wiki.action;
>>>>>>
>>>>>> -import org.apache.wiki.ui.stripes.WikiRequestContext;
>>>>>> +import java.util.ArrayList;
>>>>>> +import java.util.Collection;
>>>>>> +import java.util.Collections;
>>>>>> +import java.util.List;
>>>>>>
>>>>>> import net.sourceforge.stripes.action.*;
>>>>>> +import net.sourceforge.stripes.ajax.JavaScriptResolution;
>>>>>> +
>>>>>> +import org.apache.wiki.WikiEngine;
>>>>>> +import org.apache.wiki.api.WikiPage;
>>>>>> +import org.apache.wiki.auth.AuthorizationManager;
>>>>>> +import org.apache.wiki.auth.permissions.PagePermission;
>>>>>> +import org.apache.wiki.log.Logger;
>>>>>> +import org.apache.wiki.log.LoggerFactory;
>>>>>> +import org.apache.wiki.search.SearchResult;
>>>>>> +import org.apache.wiki.ui.stripes.WikiRequestContext;
>>>>>>
>>>>>> +/**
>>>>>> + * Searches the WikiPage collection for a given wiki.
>>>>>> + */
>>>>>> @UrlBinding( "/Search.jsp" )
>>>>>> public class SearchActionBean extends AbstractActionBean
>>>>>> {
>>>>>> +    private Logger log =  
>>>>>> LoggerFactory.getLogger("JSPWikiSearch");
>>>>>> +
>>>>>> +    public static final Collection<SearchResult> NO_RESULTS =
>>>>>> Collections.emptyList();
>>>>>> +
>>>>>> +    private Collection<SearchResult> m_results = NO_RESULTS;
>>>>>> +
>>>>>> +    private String m_query = null;
>>>>>> +
>>>>>> +    private int m_maxItems = 20;
>>>>>> +
>>>>>> +    private int m_start = 0;
>>>>>> +
>>>>>> +    private boolean m_details = false;
>>>>>> +
>>>>>> +    public boolean getDetails()
>>>>>> +    {
>>>>>> +        return m_details;
>>>>>> +    }
>>>>>> +
>>>>>> +    /**
>>>>>> +     * Sets the search results so that details for each result  
>>>>>> are
>>>>>> displayed.
>>>>>> +     * @param details whether details should be displayed
>>>>>> +     */
>>>>>> +    public void setDetails( boolean details )
>>>>>> +    {
>>>>>> +        m_details = details;
>>>>>> +    }
>>>>>> +
>>>>>> +    public int getMaxItems()
>>>>>> +    {
>>>>>> +        return m_maxItems;
>>>>>> +    }
>>>>>> +
>>>>>> +    public void setMaxItems( int maxItems )
>>>>>> +    {
>>>>>> +        m_maxItems = maxItems;
>>>>>> +    }
>>>>>> +
>>>>>> +    public int getStart()
>>>>>> +    {
>>>>>> +        return m_start;
>>>>>> +    }
>>>>>> +
>>>>>> +    public void setStart( int start )
>>>>>> +    {
>>>>>> +        m_start = start;
>>>>>> +    }
>>>>>> +
>>>>>> +    /**
>>>>>> +     * Returns the query string for the search.
>>>>>> +     *
>>>>>> +     * @return the query string
>>>>>> +     */
>>>>>> +    public String getQuery()
>>>>>> +    {
>>>>>> +        return m_query;
>>>>>> +    }
>>>>>> +
>>>>>> +    /**
>>>>>> +     * Returns the results of the search.
>>>>>> +     *
>>>>>> +     * @return the results
>>>>>> +     */
>>>>>> +    public Collection<SearchResult> getResults()
>>>>>> +    {
>>>>>> +        return m_results;
>>>>>> +    }
>>>>>> +
>>>>>> +    /**
>>>>>> +     * Returns the number of items returned by the current  
>>>>>> search.
>>>>>> +     * @return the number of items
>>>>>> +     */
>>>>>> +    public int getResultsCount()
>>>>>> +    {
>>>>>> +        return m_results.size();
>>>>>> +    }
>>>>>> +
>>>>>> +    /**
>>>>>> +     * Performs a search and returns the results as a list.  
>>>>>> For a given
>>>>>> WikiPage to
>>>>>> +     * be included in the results, the user must have  
>>>>>> permission to
>>>>>> view
>>>>>> it.
>>>>>> +     * If the underlying providers encounter an abnormal  
>>>>>> IOException or
>>>>>> other error,
>>>>>> +     * it will be added to the ActionBeanContext's validation  
>>>>>> messages
>>>>>> collection.
>>>>>> +     * @param query the query
>>>>>> +     * @return the results
>>>>>> +     */
>>>>>> +    private List<SearchResult> doSearch( String query )
>>>>>> +    {
>>>>>> +        log.info("Searching with query '"+ query + "'.");
>>>>>> +        WikiEngine engine = getContext().getEngine();
>>>>>> +        AuthorizationManager mgr =  
>>>>>> engine.getAuthorizationManager();
>>>>>> +
>>>>>> +        //
>>>>>> +        //  Filter down to only those that we actually have a
>>>>>> permission
>>>>>> to view
>>>>>> +        //
>>>>>> +        List<SearchResult> filteredResults = new
>>>>>> ArrayList<SearchResult>();
>>>>>> +        try
>>>>>> +        {
>>>>>> +            List<SearchResult> results =  
>>>>>> engine.findPages( query );
>>>>>> +            for( SearchResult result : results )
>>>>>> +            {
>>>>>> +                WikiPage page = result.getPage();
>>>>>> +                PagePermission permission = new  
>>>>>> PagePermission( page,
>>>>>> PagePermission.VIEW_ACTION );
>>>>>> +                try
>>>>>> +                {
>>>>>> +                    if( mgr.checkPermission(
>>>>>> getContext().getWikiSession(), permission ) )
>>>>>> +                    {
>>>>>> +                        filteredResults.add( result );
>>>>>> +                    }
>>>>>> +                }
>>>>>> +                catch( Exception e ) { log.error( "Searching  
>>>>>> for page "
>>>>>> +
>>>>>> page, e ); }
>>>>>> +            }
>>>>>> +        }
>>>>>> +        catch( Exception e )
>>>>>> +        {
>>>>>> +            log.debug( "Could not search using query '" +  
>>>>>> query + "'.",
>>>>>> e
>>>>>> );
>>>>>> +            Message message = new  
>>>>>> SimpleMessage( e.getMessage() );
>>>>>> +            getContext().getMessages().add( message );
>>>>>> +            e.printStackTrace();
>>>>>> +        }
>>>>>> +        return filteredResults;
>>>>>> +    }
>>>>>> +
>>>>>> +    /**
>>>>>> +     * Sets the query string for the search.
>>>>>> +     *
>>>>>> +     * @param query the query string
>>>>>> +     */
>>>>>> +    public void setQuery( String query )
>>>>>> +    {
>>>>>> +        m_query = query;
>>>>>> +    }
>>>>>> +
>>>>>> +    /**
>>>>>> +     * Searches the wiki using the query string set for this
>>>>>> +     * ActionBean. Search results are made available to  
>>>>>> callers via the
>>>>>> +     * {@link #getResults()} method (and EL expression
>>>>>> +     * <code>$wikiActionBean.results</code>).
>>>>>> +     *
>>>>>> +     * @return always returns a {@link ForwardResolution} to
>>>>>> +     *         <code>/Search.jsp</code>.
>>>>>> +     */
>>>>>>  @DefaultHandler
>>>>>> -    @HandlesEvent( "find" )
>>>>>> +    @HandlesEvent( "search" )
>>>>>>  @WikiRequestContext( "find" )
>>>>>> -    public Resolution view()
>>>>>> +    public Resolution search()
>>>>>>  {
>>>>>> +        m_results = m_query == null ? NO_RESULTS :  
>>>>>> doSearch( m_query );
>>>>>>      return new ForwardResolution( "/Search.jsp" );
>>>>>>  }
>>>>>> +
>>>>>> +    /**
>>>>>> +     * Using AJAX, searches a specified wiki space using the  
>>>>>> query
>>>>>> string
>>>>>> set for this
>>>>>> +     * ActionBean. Results are streamed back to the client as  
>>>>>> an array
>>>>>> of
>>>>>> JSON-encoded
>>>>>> +     * SearchResult objects.
>>>>>> +     *
>>>>>> +     * @return always returns a {@link JavaScriptResolution}  
>>>>>> containing
>>>>>> the
>>>>>> +     * results; this may be a zero-length array
>>>>>> +     */
>>>>>> +    @HandlesEvent( "ajaxSearch" )
>>>>>> +    public Resolution ajaxSearch()
>>>>>> +    {
>>>>>> +        m_results = m_query == null ? NO_RESULTS :  
>>>>>> doSearch( m_query );
>>>>>> +        return new JavaScriptResolution( m_results );
>>>>>> +    }
>>>>>> }
>>>>>>
>>>>>> Modified:
>>>>>>
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>> IfNoSearchResultsTag.java
>>>>>> URL:
>>>>>>
>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IfNoSearchResultsTag.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>>>
>>>>>>
>>>>>> === 
>>>>>> === 
>>>>>> === 
>>>>>> === 
>>>>>> === 
>>>>>> ===============================================================
>>>>>> ---
>>>>>>
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>> IfNoSearchResultsTag.java
>>>>>> (original)
>>>>>> +++
>>>>>>
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>> IfNoSearchResultsTag.java
>>>>>> Mon Jun  8 01:37:33 2009
>>>>>> @@ -22,8 +22,8 @@
>>>>>>
>>>>>> import java.io.IOException;
>>>>>> import java.util.Collection;
>>>>>> -import javax.servlet.jsp.PageContext;
>>>>>>
>>>>>> +import org.apache.wiki.action.SearchActionBean;
>>>>>> import org.apache.wiki.search.SearchResult;
>>>>>>
>>>>>> /**
>>>>>> @@ -36,17 +36,18 @@
>>>>>> {
>>>>>>  private static final long serialVersionUID = 0L;
>>>>>>
>>>>>> -    @SuppressWarnings("unchecked")
>>>>>>  public final int doWikiStartTag()
>>>>>>      throws IOException
>>>>>>  {
>>>>>> -        Collection<SearchResult> list =
>>>>>> (Collection< 
>>>>>> SearchResult>)pageContext.getAttribute( "searchresults",
>>>>>> -
>>>>>> PageContext.REQUEST_SCOPE );
>>>>>> -        if( list == null || list.size() == 0 )
>>>>>> -        {
>>>>>> -            return EVAL_BODY_INCLUDE;
>>>>>> +        if ( m_wikiActionBean != null && m_wikiActionBean  
>>>>>> instanceof
>>>>>> SearchActionBean )
>>>>>> +        {
>>>>>> +            boolean emptyQuery =
>>>>>> ((SearchActionBean)m_wikiActionBean).getQuery() == null;
>>>>>> +            Collection<SearchResult> results =
>>>>>> ((SearchActionBean)m_wikiActionBean).getResults();
>>>>>> +            if ( emptyQuery || results.size() > 0 )
>>>>>> +            {
>>>>>> +                return SKIP_BODY;
>>>>>> +            }
>>>>>>      }
>>>>>> -
>>>>>> -        return SKIP_BODY;
>>>>>> +        return EVAL_BODY_INCLUDE;
>>>>>>  }
>>>>>> }
>>>>>>
>>>>>> Modified:
>>>>>>
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>> SearchResultIteratorTag.java
>>>>>> URL:
>>>>>>
>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultIteratorTag.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>>>
>>>>>>
>>>>>> === 
>>>>>> === 
>>>>>> === 
>>>>>> === 
>>>>>> === 
>>>>>> ===============================================================
>>>>>> ---
>>>>>>
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>> SearchResultIteratorTag.java
>>>>>> (original)
>>>>>> +++
>>>>>>
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>> SearchResultIteratorTag.java
>>>>>> Mon Jun  8 01:37:33 2009
>>>>>> @@ -20,12 +20,12 @@
>>>>>> */
>>>>>> package org.apache.wiki.tags;
>>>>>>
>>>>>> -import java.util.ArrayList;
>>>>>> import java.util.Collection;
>>>>>>
>>>>>> -import javax.servlet.jsp.PageContext;
>>>>>> -
>>>>>> +import org.apache.wiki.action.SearchActionBean;
>>>>>> +import org.apache.wiki.action.WikiActionBean;
>>>>>> import org.apache.wiki.search.SearchResult;
>>>>>> +import org.apache.wiki.ui.stripes.WikiInterceptor;
>>>>>>
>>>>>> /**
>>>>>> * Iterator tag for the current search results, as identified by a
>>>>>> @@ -36,19 +36,17 @@
>>>>>>  private static final long serialVersionUID = 1L;
>>>>>>
>>>>>>  /**
>>>>>> -     * \ Returns the list of SearchResults to iterate over.
>>>>>> +     * Returns the list of SearchResults to iterate over.
>>>>>>   */
>>>>>>  @Override
>>>>>> -    @SuppressWarnings( "unchecked" )
>>>>>>  protected Collection<SearchResult> initItems()
>>>>>>  {
>>>>>> -        Collection<SearchResult> results =  
>>>>>> (Collection<SearchResult>)
>>>>>> pageContext.getAttribute( "searchresults",
>>>>>> -
>>>>>>                   PageContext.REQUEST_SCOPE );
>>>>>> -        if( results == null )
>>>>>> +        WikiActionBean actionBean =  
>>>>>> WikiInterceptor.findActionBean(
>>>>>> pageContext );
>>>>>> +        if ( actionBean != null && actionBean instanceof
>>>>>> SearchActionBean
>>>>>> )
>>>>>>      {
>>>>>> -            return new ArrayList<SearchResult>();
>>>>>> +            return ((SearchActionBean)actionBean).getResults();
>>>>>>      }
>>>>>> -        return results;
>>>>>> +        return SearchActionBean.NO_RESULTS;
>>>>>>  }
>>>>>>
>>>>>>  /**
>>>>>>
>>>>>> Modified:
>>>>>>
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>> SearchResultsSizeTag.java
>>>>>> URL:
>>>>>>
>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsSizeTag.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>>>
>>>>>>
>>>>>> === 
>>>>>> === 
>>>>>> === 
>>>>>> === 
>>>>>> === 
>>>>>> ===============================================================
>>>>>> ---
>>>>>>
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>> SearchResultsSizeTag.java
>>>>>> (original)
>>>>>> +++
>>>>>>
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>> SearchResultsSizeTag.java
>>>>>> Mon Jun  8 01:37:33 2009
>>>>>> @@ -22,8 +22,8 @@
>>>>>>
>>>>>> import java.io.IOException;
>>>>>> import java.util.Collection;
>>>>>> -import javax.servlet.jsp.PageContext;
>>>>>>
>>>>>> +import org.apache.wiki.action.SearchActionBean;
>>>>>> import org.apache.wiki.search.SearchResult;
>>>>>>
>>>>>> /**
>>>>>> @@ -37,17 +37,14 @@
>>>>>> {
>>>>>>  private static final long serialVersionUID = 0L;
>>>>>>
>>>>>> -    @SuppressWarnings("unchecked")
>>>>>>  public final int doWikiStartTag()
>>>>>>      throws IOException
>>>>>>  {
>>>>>> -        Collection<SearchResult> list =
>>>>>> (Collection< 
>>>>>> SearchResult>)pageContext.getAttribute( "searchresults",
>>>>>> -
>>>>>> PageContext.REQUEST_SCOPE );
>>>>>> -        if( list != null )
>>>>>> +        if ( m_wikiActionBean != null && m_wikiActionBean  
>>>>>> instanceof
>>>>>> SearchActionBean )
>>>>>>      {
>>>>>> -            pageContext.getOut().print( list.size() );
>>>>>> +            Collection<SearchResult> results =
>>>>>> ((SearchActionBean)m_wikiActionBean).getResults();
>>>>>> +            pageContext.getOut().print( results.size() );
>>>>>>      }
>>>>>> -
>>>>>>      return SKIP_BODY;
>>>>>>  }
>>>>>> }
>>>>>>
>>>>>> Modified:
>>>>>>
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>> SearchResultsTag.java
>>>>>> URL:
>>>>>>
>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsTag.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>>>
>>>>>>
>>>>>> === 
>>>>>> === 
>>>>>> === 
>>>>>> === 
>>>>>> === 
>>>>>> ===============================================================
>>>>>> ---
>>>>>>
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>> SearchResultsTag.java
>>>>>> (original)
>>>>>> +++
>>>>>>
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>> SearchResultsTag.java
>>>>>> Mon Jun  8 01:37:33 2009
>>>>>> @@ -21,10 +21,10 @@
>>>>>> package org.apache.wiki.tags;
>>>>>>
>>>>>> import java.io.IOException;
>>>>>> -import java.util.Collection;
>>>>>> +
>>>>>> import javax.servlet.jsp.PageContext;
>>>>>>
>>>>>> -import org.apache.wiki.search.SearchResult;
>>>>>> +import org.apache.wiki.action.SearchActionBean;
>>>>>>
>>>>>> /**
>>>>>> *  Includes the body content, if there are any search results.
>>>>>> @@ -36,16 +36,16 @@
>>>>>> {
>>>>>>  private static final long serialVersionUID = 0L;
>>>>>>
>>>>>> -    @SuppressWarnings("unchecked")
>>>>>>  public final int doWikiStartTag()
>>>>>>      throws IOException
>>>>>>  {
>>>>>> -        Collection<SearchResult> list =
>>>>>> (Collection< 
>>>>>> SearchResult>)pageContext.getAttribute( "searchresults",
>>>>>> -
>>>>>> PageContext.REQUEST_SCOPE );
>>>>>> -
>>>>>> -        if( list != null )
>>>>>> +        if ( m_wikiActionBean != null && m_wikiActionBean  
>>>>>> instanceof
>>>>>> SearchActionBean )
>>>>>>      {
>>>>>> -            return EVAL_BODY_INCLUDE;
>>>>>> +            boolean emptyQuery =
>>>>>> ((SearchActionBean)m_wikiActionBean).getQuery() == null;
>>>>>> +            if ( !emptyQuery )
>>>>>> +            {
>>>>>> +                return EVAL_BODY_INCLUDE;
>>>>>> +            }
>>>>>>      }
>>>>>>
>>>>>>      String message = (String)pageContext.getAttribute( "err",
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>
>

Re: svn commit: r782495 - in /incubator/jspwiki/trunk/src: WebContent/ WebContent/scripts/ WebContent/templates/default/ java/org/apache/wiki/ java/org/apache/wiki/action/ java/org/apache/wiki/tags/

Posted by Janne Jalkanen <ja...@ecyrd.com>.
That would be good so we can get rid of jabsorb, jsonrpc and the  
GlobalRPCBridge (which is amazingly huge, as documented by someone).

I can probably do some hacking on the serverside over the weekend as  
well.

/Janne

On 9 Jun 2009, at 21:03, Dirk Frederickx wrote:

> Janne, Andrew,
>
>
> Wiki.jsonrpc() is pretty much doing what you are  suggesting.
> It just needs an update not to work anymore with JsonRPC but with  
> hook-up
> with Stripes' approach to ajax.
>
> This shouldn't be to hard to figure out.
> I'll check this out over the weekend, unless anyone is moving  
> faster ;-)
>
>
> dirk
>
> On Mon, Jun 8, 2009 at 9:53 PM, Janne Jalkanen <janne.jalkanen@ecyrd.com 
> >wrote:
>
>>
>> Reminds me - the JS code used to call Ajax routines is disgustingly
>> loathsome and makes my eyes bleed and my stomach retch.  Can we  
>> upgrade to a
>> newer Mootools lib (1.2.2, I think) and switch to Request.JSON and  
>> create a
>> JSONFactory or an extension for creating our AJAX requests?
>>
>> Something like wiki.json( "Search", "ajaxSearch", { param1 :  
>> value1, ... },
>> callback(resultobj,resulttext) ); would be nice. This would  
>> construct the
>> URL to SearchActionBean, method ajaxSearch, with the given params.
>>
>> /Janne
>>
>> On 8 Jun 2009, at 21:52, Andrew Jaquith wrote:
>>
>> It will fix this one -- but only after we've hooked it up to the
>>> client JavaScript. Should not take long.
>>>
>>> On Mon, Jun 8, 2009 at 2:44 PM, Harry Metske<ha...@gmail.com>
>>> wrote:
>>>
>>>> Andrew,
>>>>
>>>> should this patch have fixed
>>>> https://issues.apache.org/jira/browse/JSPWIKI-510 (only for 3.0 of
>>>> course) ?
>>>>
>>>> Harry
>>>>
>>>> 2009/6/8 <aj...@apache.org>
>>>>
>>>>
>>>> Author: ajaquith
>>>>> Date: Mon Jun  8 01:37:33 2009
>>>>> New Revision: 782495
>>>>>
>>>>> URL: http://svn.apache.org/viewvc?rev=782495&view=rev
>>>>> Log:
>>>>> Search.jsp migrated to Stripes. SearchActionBean now provides  
>>>>> searching
>>>>> logic, including an ajaxSearch() method that filters results  
>>>>> correctly
>>>>> (this
>>>>> is not hooked up to the client JavaScript yet, but it should be
>>>>> straightforward to do). Still some i18n cleanup to do.
>>>>>
>>>>> Modified:
>>>>>  incubator/jspwiki/trunk/src/WebContent/Search.jsp
>>>>>  incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-common.js
>>>>>
>>>>> incubator/jspwiki/trunk/src/WebContent/templates/default/ 
>>>>> FindContent.jsp
>>>>>  incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiContext.java
>>>>>
>>>>>
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/action/ 
>>>>> SearchActionBean.java
>>>>>
>>>>>
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>> IfNoSearchResultsTag.java
>>>>>
>>>>>
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>> SearchResultIteratorTag.java
>>>>>
>>>>>
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>> SearchResultsSizeTag.java
>>>>>
>>>>>
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>> SearchResultsTag.java
>>>>>
>>>>> Modified: incubator/jspwiki/trunk/src/WebContent/Search.jsp
>>>>> URL:
>>>>>
>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/WebContent/Search.jsp?rev=782495&r1=782494&r2=782495&view=diff
>>>>>
>>>>>
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> ==================================================================
>>>>> --- incubator/jspwiki/trunk/src/WebContent/Search.jsp (original)
>>>>> +++ incubator/jspwiki/trunk/src/WebContent/Search.jsp Mon Jun  8
>>>>> 01:37:33
>>>>> 2009
>>>>> @@ -18,108 +18,12 @@
>>>>>   specific language governing permissions and limitations
>>>>>   under the License.
>>>>> --%>
>>>>> -<%@ page import="org.apache.wiki.log.Logger" %>
>>>>> -<%@ page import="org.apache.wiki.log.LoggerFactory" %>
>>>>> -<%@ page import="org.apache.wiki.*" %>
>>>>> -<%@ page import="org.apache.wiki.auth.*" %>
>>>>> -<%@ page import="org.apache.wiki.auth.permissions.*" %>
>>>>> -<%@ page import="java.util.*" %>
>>>>> +<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld"  
>>>>> prefix="s"
>>>>> %>
>>>>> <%@ page errorPage="/Error.jsp" %>
>>>>> -<%@ page import="org.apache.wiki.search.*" %>
>>>>> -<%@ taglib uri="http://jakarta.apache.org/jspwiki.tld"  
>>>>> prefix="wiki"
>>>>> %>
>>>>> -<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld"
>>>>> prefix="stripes" %>
>>>>> -<%@ page import="org.apache.wiki.util.TextUtil" %>
>>>>> -<%@ page import="org.apache.wiki.api.WikiPage" %>
>>>>> -<stripes:useActionBean
>>>>> beanclass="org.apache.wiki.action.SearchActionBean"
>>>>> event="find" id="wikiActionBean" />
>>>>> +<s:useActionBean  
>>>>> beanclass="org.apache.wiki.action.SearchActionBean"
>>>>> event="search" executeResolution="true" id="wikiActionBean" />
>>>>> +<s:layout-render name="${templates['DefaultLayout.jsp']}">
>>>>> +  <s:layout-component name="content">
>>>>> +      <jsp:include page="${templates['FindContent.jsp']}" />
>>>>> +  </s:layout-component>
>>>>> +</s:layout-render>
>>>>>
>>>>> -<%!
>>>>> -    Logger log = LoggerFactory.getLogger("JSPWikiSearch");
>>>>> -%>
>>>>> -
>>>>> -<%
>>>>> -    WikiEngine wiki =  
>>>>> WikiEngine.getInstance( getServletConfig() );
>>>>> -    // Create wiki context and check for authorization
>>>>> -    WikiContext wikiContext = wiki.createContext( request,
>>>>> WikiContext.FIND );
>>>>> -    String pagereq = wikiContext.getPage().getName();
>>>>> -
>>>>> -    // Get the search results
>>>>> -    Collection list = null;
>>>>> -    String query = request.getParameter( "query");
>>>>> -    String go    = request.getParameter("go");
>>>>> -
>>>>> -    if( query != null )
>>>>> -    {
>>>>> -        log.info("Searching for string "+query);
>>>>> -
>>>>> -        try
>>>>> -        {
>>>>> -            list = wiki.findPages( query );
>>>>> -
>>>>> -            //
>>>>> -            //  Filter down to only those that we actually have a
>>>>> permission to view
>>>>> -            //
>>>>> -            AuthorizationManager mgr =  
>>>>> wiki.getAuthorizationManager();
>>>>> -
>>>>> -            ArrayList filteredList = new ArrayList();
>>>>> -
>>>>> -            for( Iterator i = list.iterator(); i.hasNext(); )
>>>>> -            {
>>>>> -                SearchResult r = (SearchResult)i.next();
>>>>> -
>>>>> -                WikiPage p = r.getPage();
>>>>> -
>>>>> -                PagePermission pp = new PagePermission( p,
>>>>> PagePermission.VIEW_ACTION );
>>>>> -
>>>>> -                try
>>>>> -                {
>>>>> -                    if( mgr.checkPermission(
>>>>> wikiContext.getWikiSession(),
>>>>> pp ) )
>>>>> -                    {
>>>>> -                        filteredList.add( r );
>>>>> -                    }
>>>>> -                }
>>>>> -                catch( Exception e ) { log.error( "Searching  
>>>>> for page
>>>>> "+p,
>>>>> e ); }
>>>>> -            }
>>>>> -
>>>>> -            pageContext.setAttribute( "searchresults",
>>>>> -                                      filteredList,
>>>>> -                                       
>>>>> PageContext.REQUEST_SCOPE );
>>>>> -        }
>>>>> -        catch( Exception e )
>>>>> -        {
>>>>> -             
>>>>> wikiContext.getWikiSession().addMessage( e.getMessage() );
>>>>> -        }
>>>>> -
>>>>> -        query = TextUtil.replaceEntities( query );
>>>>> -
>>>>> -        pageContext.setAttribute( "query",
>>>>> -                                  query,
>>>>> -                                  PageContext.REQUEST_SCOPE );
>>>>> -
>>>>> -        //
>>>>> -        //  Did the user click on "go"?
>>>>> -        //
>>>>> -        if( go != null )
>>>>> -        {
>>>>> -            if( list != null && list.size() > 0 )
>>>>> -            {
>>>>> -                SearchResult sr = (SearchResult)
>>>>> list.iterator().next();
>>>>> -
>>>>> -                WikiPage wikiPage = sr.getPage();
>>>>> -
>>>>> -                String url =  
>>>>> wikiContext.getViewURL( wikiPage.getName()
>>>>> );
>>>>> -
>>>>> -                response.sendRedirect( url );
>>>>> -
>>>>> -                return;
>>>>> -            }
>>>>> -        }
>>>>> -    }
>>>>> -
>>>>> -    // Set the content type and include the response content
>>>>> -    response.setContentType("text/html;
>>>>> charset="+wiki.getContentEncoding() );
>>>>> -    String contentPage = wiki.getTemplateManager().findJSP(
>>>>> pageContext,
>>>>> -
>>>>> wikiContext.getTemplate(),
>>>>> -
>>>>> "ViewTemplate.jsp" );
>>>>> -%><wiki:Include page="<%=contentPage%>" /><%
>>>>> -    log.debug("SEARCH COMPLETE");
>>>>> -%>
>>>>>
>>>>> Modified:
>>>>> incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-common.js
>>>>> URL:
>>>>>
>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-common.js?rev=782495&r1=782494&r2=782495&view=diff
>>>>>
>>>>>
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> ==================================================================
>>>>> --- incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki- 
>>>>> common.js
>>>>> (original)
>>>>> +++ incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki- 
>>>>> common.js Mon
>>>>> Jun  8 01:37:33 2009
>>>>> @@ -931,9 +931,9 @@
>>>>>                      if (option.value == match) option.selected  
>>>>> = true;
>>>>>              });
>>>>>
>>>>> -               new Ajax(Wiki.TemplateUrl+'AJAXSearch.jsp', {
>>>>> -                       postBody: $ 
>>>>> ('searchform2').toQueryString(),
>>>>> -                       update: 'searchResult2',
>>>>> +               new Ajax(Wiki.BasePath+'Search.action', {
>>>>> +                       postBody:
>>>>> "ajaxSearch=&"+$('searchform2').toQueryString(),
>>>>> +                       update: 'searchResult2',
>>>>>                      method: 'post',
>>>>>                      onComplete: function() {
>>>>>                              $('spin').hide();
>>>>>
>>>>> Modified:
>>>>> incubator/jspwiki/trunk/src/WebContent/templates/default/ 
>>>>> FindContent.jsp
>>>>> URL:
>>>>>
>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/WebContent/templates/default/FindContent.jsp?rev=782495&r1=782494&r2=782495&view=diff
>>>>>
>>>>>
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> ==================================================================
>>>>> ---
>>>>> incubator/jspwiki/trunk/src/WebContent/templates/default/ 
>>>>> FindContent.jsp
>>>>> (original)
>>>>> +++
>>>>> incubator/jspwiki/trunk/src/WebContent/templates/default/ 
>>>>> FindContent.jsp
>>>>> Mon
>>>>> Jun  8 01:37:33 2009
>>>>> @@ -27,24 +27,18 @@
>>>>> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
>>>>> <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
>>>>> <%@ page import="javax.servlet.jsp.jstl.fmt.*" %>
>>>>> -<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld"
>>>>> prefix="stripes" %>
>>>>> +<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld"  
>>>>> prefix="s"
>>>>> %>
>>>>>
>>>>> <wiki:TabbedSection>
>>>>> <wiki:Tab id="findcontent" titleKey="find.tab" accesskey="s">
>>>>>
>>>>> -<form action="<wiki:Link format='url' jsp='Search.jsp'/>"
>>>>> -       class="wikiform"
>>>>> -          id="searchform2"
>>>>> -         accept-charset="<wiki:ContentEncoding/>">
>>>>> -
>>>>> +<s:form beanclass="org.apache.wiki.action.SearchActionBean"
>>>>> class="wikiform"
>>>>> +    id="searchform2" acceptcharset="UTF-8">
>>>>> +
>>>>> <h4><fmt:message key="find.input" /></h4>
>>>>> <p>
>>>>> -    <input type="text"
>>>>> -           name="query" id="query2"
>>>>> -          value="<c:out value='${query}'/>"
>>>>> -           size="32" />
>>>>> -
>>>>> -    <input type="checkbox" name="details" id="details" <c:if
>>>>> test='${param.details == "on"}'>checked='checked'</c:if> />
>>>>> +    <s:text name="query" id="query2" size="32" />
>>>>> +    <s:checkbox name="details" id="details" />
>>>>>   <fmt:message key="find.details" />
>>>>>
>>>>>   <select name="scope" id="scope">
>>>>> @@ -55,16 +49,83 @@
>>>>>     <option value="attachment:" <c:if test='${param.scope eq
>>>>> "attachment:"}'>selected="selected"</c:if> ><fmt:message
>>>>> key='find.scope.attach' /></option>
>>>>>   </select>
>>>>>
>>>>> -       <input type="submit" name="ok" id="ok" value="<fmt:message
>>>>> key="find.submit.find" />" />
>>>>> -       <input type="submit" name="go" id="go" value="<fmt:message
>>>>> key="find.submit.go" />" />
>>>>> -    <input type="hidden" name="start" id="start" value="0" />
>>>>> -    <input type="hidden" name="maxitems" id="maxitems"  
>>>>> value="20" />
>>>>> +    <s:submit name="search" id="ok" value="<fmt:message
>>>>> key='find.submit.find' />" />
>>>>> +    <s:submit name="go" id="go" value="<fmt:message
>>>>> key='find.submit.go'
>>>>> />" />
>>>>> +    <s:hidden name="start" id="start" value="0" />
>>>>> +    <s:hidden name="maxItems" id="maxitems" value="20" />
>>>>>
>>>>>   <span id="spin" class="spin"
>>>>> style="position:absolute;display:none;"></span>
>>>>> </p>
>>>>> -</form>
>>>>> +</s:form>
>>>>> +
>>>>> +<div id="searchResult2">
>>>>> +  <wiki:SearchResults>
>>>>> +
>>>>> +    <h4><fmt:message key="find.heading.results"><fmt:param><c:out
>>>>> value="${wikiActionBean.query}" /></fmt:param></fmt:message></h4>
>>>>> +    <p>
>>>>> +      <fmt:message key="find.externalsearch" />
>>>>> +      <a class="external" href="http://www.google.com/search? 
>>>>> q=<c:out
>>>>> value='${wikiActionBean.query}' />" title="Google Search '<c:out
>>>>> value='${wikiActionBean.query}' />'" target="_blank">Google</ 
>>>>> a><img
>>>>> class="outlink" src="images/out.png" alt="" />
>>>>> +      |
>>>>> +      <a class="external" href="
>>>>> http://en.wikipedia.org/wiki/Special:Search?search=<c:out
>>>>> value='${wikiActionBean.query}' />" title="Wikipedia Search  
>>>>> '<c:out
>>>>> value='${wikiActionBean.query}' />'" target="_blank">Wikipedia</ 
>>>>> a><img
>>>>> class="outlink" src="images/out.png" alt="" />
>>>>> +    </p>
>>>>> +
>>>>> +    <wiki:SetPagination start="${wikiActionBean.start}"
>>>>> total="${wikiActionBean.resultsCount}" pagesize="20" maxlinks="9"
>>>>> fmtkey="info.pagination" onclick="$('start').value=%s;
>>>>> SearchBox.runfullsearch();" />
>>>>> +
>>>>> +    <div class="graphBars">
>>>>> +      <div class="zebra-table">
>>>>> +        <table class="wikitable">
>>>>> +
>>>>> +          <tr>
>>>>> +             <th align="left"><fmt:message  
>>>>> key="find.results.page"
>>>>> /></th>
>>>>> +             <th align="left"><fmt:message  
>>>>> key="find.results.score"
>>>>> /></th>
>>>>> +          </tr>
>>>>> +
>>>>> +          <wiki:SearchResultIterator id="searchref"
>>>>> start="${wikiActionBean.start}" maxItems="$ 
>>>>> {wikiActionBean.maxItems}">
>>>>> +          <tr>
>>>>> +            <td><wiki:LinkTo><wiki:PageName/></wiki:LinkTo></td>
>>>>> +            <td><span class="gBar"><%= searchref.getScore()
>>>>> %></span></td>
>>>>> +          </tr>
>>>>> +
>>>>> +          <c:if test="${wikiActionBean.details == 'true'}">
>>>>> +  <%
>>>>> +            String[] contexts = searchref.getContexts();
>>>>> +            if( (contexts != null) && (contexts.length > 0) )
>>>>> +            {
>>>>> +  %>
>>>>> +          <tr class="odd">
>>>>> +            <td colspan="2">
>>>>> +              <div class="fragment">
>>>>> +  <%
>>>>> +              for (int i = 0; i < contexts.length; i++)
>>>>> +              {
>>>>> +  %>
>>>>> +                <%= (i > 0 ) ? "<span  
>>>>> class='fragment_ellipsis'> ...
>>>>> </span>" : ""  %>
>>>>> +                <%= contexts[i]  %>
>>>>> +  <%
>>>>> +              }
>>>>> +  %>
>>>>> +               </div>
>>>>> +             </td>
>>>>> +           </tr>
>>>>> +  <%
>>>>> +            }
>>>>> +  %>
>>>>> +          </c:if><%-- details --%>
>>>>> +        </wiki:SearchResultIterator>
>>>>> +
>>>>> +        <wiki:IfNoSearchResults>
>>>>> +          <tr>
>>>>> +            <td class="nosearchresult" colspan="2"><fmt:message
>>>>> key="find.noresults" /></td>
>>>>> +          </tr>
>>>>> +        </wiki:IfNoSearchResults>
>>>>> +
>>>>> +        </table>
>>>>> +      </div>
>>>>> +    </div>
>>>>> +    ${pagination}
>>>>>
>>>>> -<div id="searchResult2"><wiki:Include page="AJAXSearch.jsp" /></ 
>>>>> div>
>>>>> +  </wiki:SearchResults>
>>>>> +</div>
>>>>>
>>>>> </wiki:Tab>
>>>>>
>>>>>
>>>>> Modified:
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiContext.java
>>>>> URL:
>>>>>
>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiContext.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>>
>>>>>
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> ==================================================================
>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/ 
>>>>> WikiContext.java
>>>>> (original)
>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/ 
>>>>> WikiContext.java
>>>>> Mon
>>>>> Jun  8 01:37:33 2009
>>>>> @@ -103,7 +103,7 @@
>>>>>   public static final String    COMMENT  =  
>>>>> HandlerInfo.getHandlerInfo(
>>>>> EditActionBean.class, "comment" ).getRequestContext();
>>>>>
>>>>>   /** User is searching for content. */
>>>>> -    public static final String    FIND     =
>>>>> HandlerInfo.getHandlerInfo(
>>>>> SearchActionBean.class, "find" ).getRequestContext();
>>>>> +    public static final String    FIND     =
>>>>> HandlerInfo.getHandlerInfo(
>>>>> SearchActionBean.class, "search" ).getRequestContext();
>>>>>
>>>>>   /** User wishes to create a new group */
>>>>>   public static final String    CREATE_GROUP =
>>>>> HandlerInfo.getHandlerInfo( GroupActionBean.class, "create"
>>>>> ).getRequestContext();
>>>>>
>>>>> Modified:
>>>>>
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/action/ 
>>>>> SearchActionBean.java
>>>>> URL:
>>>>>
>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/action/SearchActionBean.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>>
>>>>>
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> ==================================================================
>>>>> ---
>>>>>
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/action/ 
>>>>> SearchActionBean.java
>>>>> (original)
>>>>> +++
>>>>>
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/action/ 
>>>>> SearchActionBean.java
>>>>> Mon Jun  8 01:37:33 2009
>>>>> @@ -21,18 +21,191 @@
>>>>>
>>>>> package org.apache.wiki.action;
>>>>>
>>>>> -import org.apache.wiki.ui.stripes.WikiRequestContext;
>>>>> +import java.util.ArrayList;
>>>>> +import java.util.Collection;
>>>>> +import java.util.Collections;
>>>>> +import java.util.List;
>>>>>
>>>>> import net.sourceforge.stripes.action.*;
>>>>> +import net.sourceforge.stripes.ajax.JavaScriptResolution;
>>>>> +
>>>>> +import org.apache.wiki.WikiEngine;
>>>>> +import org.apache.wiki.api.WikiPage;
>>>>> +import org.apache.wiki.auth.AuthorizationManager;
>>>>> +import org.apache.wiki.auth.permissions.PagePermission;
>>>>> +import org.apache.wiki.log.Logger;
>>>>> +import org.apache.wiki.log.LoggerFactory;
>>>>> +import org.apache.wiki.search.SearchResult;
>>>>> +import org.apache.wiki.ui.stripes.WikiRequestContext;
>>>>>
>>>>> +/**
>>>>> + * Searches the WikiPage collection for a given wiki.
>>>>> + */
>>>>> @UrlBinding( "/Search.jsp" )
>>>>> public class SearchActionBean extends AbstractActionBean
>>>>> {
>>>>> +    private Logger log =  
>>>>> LoggerFactory.getLogger("JSPWikiSearch");
>>>>> +
>>>>> +    public static final Collection<SearchResult> NO_RESULTS =
>>>>> Collections.emptyList();
>>>>> +
>>>>> +    private Collection<SearchResult> m_results = NO_RESULTS;
>>>>> +
>>>>> +    private String m_query = null;
>>>>> +
>>>>> +    private int m_maxItems = 20;
>>>>> +
>>>>> +    private int m_start = 0;
>>>>> +
>>>>> +    private boolean m_details = false;
>>>>> +
>>>>> +    public boolean getDetails()
>>>>> +    {
>>>>> +        return m_details;
>>>>> +    }
>>>>> +
>>>>> +    /**
>>>>> +     * Sets the search results so that details for each result  
>>>>> are
>>>>> displayed.
>>>>> +     * @param details whether details should be displayed
>>>>> +     */
>>>>> +    public void setDetails( boolean details )
>>>>> +    {
>>>>> +        m_details = details;
>>>>> +    }
>>>>> +
>>>>> +    public int getMaxItems()
>>>>> +    {
>>>>> +        return m_maxItems;
>>>>> +    }
>>>>> +
>>>>> +    public void setMaxItems( int maxItems )
>>>>> +    {
>>>>> +        m_maxItems = maxItems;
>>>>> +    }
>>>>> +
>>>>> +    public int getStart()
>>>>> +    {
>>>>> +        return m_start;
>>>>> +    }
>>>>> +
>>>>> +    public void setStart( int start )
>>>>> +    {
>>>>> +        m_start = start;
>>>>> +    }
>>>>> +
>>>>> +    /**
>>>>> +     * Returns the query string for the search.
>>>>> +     *
>>>>> +     * @return the query string
>>>>> +     */
>>>>> +    public String getQuery()
>>>>> +    {
>>>>> +        return m_query;
>>>>> +    }
>>>>> +
>>>>> +    /**
>>>>> +     * Returns the results of the search.
>>>>> +     *
>>>>> +     * @return the results
>>>>> +     */
>>>>> +    public Collection<SearchResult> getResults()
>>>>> +    {
>>>>> +        return m_results;
>>>>> +    }
>>>>> +
>>>>> +    /**
>>>>> +     * Returns the number of items returned by the current  
>>>>> search.
>>>>> +     * @return the number of items
>>>>> +     */
>>>>> +    public int getResultsCount()
>>>>> +    {
>>>>> +        return m_results.size();
>>>>> +    }
>>>>> +
>>>>> +    /**
>>>>> +     * Performs a search and returns the results as a list. For  
>>>>> a given
>>>>> WikiPage to
>>>>> +     * be included in the results, the user must have  
>>>>> permission to
>>>>> view
>>>>> it.
>>>>> +     * If the underlying providers encounter an abnormal  
>>>>> IOException or
>>>>> other error,
>>>>> +     * it will be added to the ActionBeanContext's validation  
>>>>> messages
>>>>> collection.
>>>>> +     * @param query the query
>>>>> +     * @return the results
>>>>> +     */
>>>>> +    private List<SearchResult> doSearch( String query )
>>>>> +    {
>>>>> +        log.info("Searching with query '"+ query + "'.");
>>>>> +        WikiEngine engine = getContext().getEngine();
>>>>> +        AuthorizationManager mgr =  
>>>>> engine.getAuthorizationManager();
>>>>> +
>>>>> +        //
>>>>> +        //  Filter down to only those that we actually have a
>>>>> permission
>>>>> to view
>>>>> +        //
>>>>> +        List<SearchResult> filteredResults = new
>>>>> ArrayList<SearchResult>();
>>>>> +        try
>>>>> +        {
>>>>> +            List<SearchResult> results =  
>>>>> engine.findPages( query );
>>>>> +            for( SearchResult result : results )
>>>>> +            {
>>>>> +                WikiPage page = result.getPage();
>>>>> +                PagePermission permission = new  
>>>>> PagePermission( page,
>>>>> PagePermission.VIEW_ACTION );
>>>>> +                try
>>>>> +                {
>>>>> +                    if( mgr.checkPermission(
>>>>> getContext().getWikiSession(), permission ) )
>>>>> +                    {
>>>>> +                        filteredResults.add( result );
>>>>> +                    }
>>>>> +                }
>>>>> +                catch( Exception e ) { log.error( "Searching  
>>>>> for page "
>>>>> +
>>>>> page, e ); }
>>>>> +            }
>>>>> +        }
>>>>> +        catch( Exception e )
>>>>> +        {
>>>>> +            log.debug( "Could not search using query '" + query  
>>>>> + "'.",
>>>>> e
>>>>> );
>>>>> +            Message message = new  
>>>>> SimpleMessage( e.getMessage() );
>>>>> +            getContext().getMessages().add( message );
>>>>> +            e.printStackTrace();
>>>>> +        }
>>>>> +        return filteredResults;
>>>>> +    }
>>>>> +
>>>>> +    /**
>>>>> +     * Sets the query string for the search.
>>>>> +     *
>>>>> +     * @param query the query string
>>>>> +     */
>>>>> +    public void setQuery( String query )
>>>>> +    {
>>>>> +        m_query = query;
>>>>> +    }
>>>>> +
>>>>> +    /**
>>>>> +     * Searches the wiki using the query string set for this
>>>>> +     * ActionBean. Search results are made available to callers  
>>>>> via the
>>>>> +     * {@link #getResults()} method (and EL expression
>>>>> +     * <code>$wikiActionBean.results</code>).
>>>>> +     *
>>>>> +     * @return always returns a {@link ForwardResolution} to
>>>>> +     *         <code>/Search.jsp</code>.
>>>>> +     */
>>>>>   @DefaultHandler
>>>>> -    @HandlesEvent( "find" )
>>>>> +    @HandlesEvent( "search" )
>>>>>   @WikiRequestContext( "find" )
>>>>> -    public Resolution view()
>>>>> +    public Resolution search()
>>>>>   {
>>>>> +        m_results = m_query == null ? NO_RESULTS :  
>>>>> doSearch( m_query );
>>>>>       return new ForwardResolution( "/Search.jsp" );
>>>>>   }
>>>>> +
>>>>> +    /**
>>>>> +     * Using AJAX, searches a specified wiki space using the  
>>>>> query
>>>>> string
>>>>> set for this
>>>>> +     * ActionBean. Results are streamed back to the client as  
>>>>> an array
>>>>> of
>>>>> JSON-encoded
>>>>> +     * SearchResult objects.
>>>>> +     *
>>>>> +     * @return always returns a {@link JavaScriptResolution}  
>>>>> containing
>>>>> the
>>>>> +     * results; this may be a zero-length array
>>>>> +     */
>>>>> +    @HandlesEvent( "ajaxSearch" )
>>>>> +    public Resolution ajaxSearch()
>>>>> +    {
>>>>> +        m_results = m_query == null ? NO_RESULTS :  
>>>>> doSearch( m_query );
>>>>> +        return new JavaScriptResolution( m_results );
>>>>> +    }
>>>>> }
>>>>>
>>>>> Modified:
>>>>>
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>> IfNoSearchResultsTag.java
>>>>> URL:
>>>>>
>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IfNoSearchResultsTag.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>>
>>>>>
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> ==================================================================
>>>>> ---
>>>>>
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>> IfNoSearchResultsTag.java
>>>>> (original)
>>>>> +++
>>>>>
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>> IfNoSearchResultsTag.java
>>>>> Mon Jun  8 01:37:33 2009
>>>>> @@ -22,8 +22,8 @@
>>>>>
>>>>> import java.io.IOException;
>>>>> import java.util.Collection;
>>>>> -import javax.servlet.jsp.PageContext;
>>>>>
>>>>> +import org.apache.wiki.action.SearchActionBean;
>>>>> import org.apache.wiki.search.SearchResult;
>>>>>
>>>>> /**
>>>>> @@ -36,17 +36,18 @@
>>>>> {
>>>>>   private static final long serialVersionUID = 0L;
>>>>>
>>>>> -    @SuppressWarnings("unchecked")
>>>>>   public final int doWikiStartTag()
>>>>>       throws IOException
>>>>>   {
>>>>> -        Collection<SearchResult> list =
>>>>> (Collection 
>>>>> <SearchResult>)pageContext.getAttribute( "searchresults",
>>>>> -
>>>>> PageContext.REQUEST_SCOPE );
>>>>> -        if( list == null || list.size() == 0 )
>>>>> -        {
>>>>> -            return EVAL_BODY_INCLUDE;
>>>>> +        if ( m_wikiActionBean != null && m_wikiActionBean  
>>>>> instanceof
>>>>> SearchActionBean )
>>>>> +        {
>>>>> +            boolean emptyQuery =
>>>>> ((SearchActionBean)m_wikiActionBean).getQuery() == null;
>>>>> +            Collection<SearchResult> results =
>>>>> ((SearchActionBean)m_wikiActionBean).getResults();
>>>>> +            if ( emptyQuery || results.size() > 0 )
>>>>> +            {
>>>>> +                return SKIP_BODY;
>>>>> +            }
>>>>>       }
>>>>> -
>>>>> -        return SKIP_BODY;
>>>>> +        return EVAL_BODY_INCLUDE;
>>>>>   }
>>>>> }
>>>>>
>>>>> Modified:
>>>>>
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>> SearchResultIteratorTag.java
>>>>> URL:
>>>>>
>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultIteratorTag.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>>
>>>>>
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> ==================================================================
>>>>> ---
>>>>>
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>> SearchResultIteratorTag.java
>>>>> (original)
>>>>> +++
>>>>>
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>> SearchResultIteratorTag.java
>>>>> Mon Jun  8 01:37:33 2009
>>>>> @@ -20,12 +20,12 @@
>>>>> */
>>>>> package org.apache.wiki.tags;
>>>>>
>>>>> -import java.util.ArrayList;
>>>>> import java.util.Collection;
>>>>>
>>>>> -import javax.servlet.jsp.PageContext;
>>>>> -
>>>>> +import org.apache.wiki.action.SearchActionBean;
>>>>> +import org.apache.wiki.action.WikiActionBean;
>>>>> import org.apache.wiki.search.SearchResult;
>>>>> +import org.apache.wiki.ui.stripes.WikiInterceptor;
>>>>>
>>>>> /**
>>>>> * Iterator tag for the current search results, as identified by a
>>>>> @@ -36,19 +36,17 @@
>>>>>   private static final long serialVersionUID = 1L;
>>>>>
>>>>>   /**
>>>>> -     * \ Returns the list of SearchResults to iterate over.
>>>>> +     * Returns the list of SearchResults to iterate over.
>>>>>    */
>>>>>   @Override
>>>>> -    @SuppressWarnings( "unchecked" )
>>>>>   protected Collection<SearchResult> initItems()
>>>>>   {
>>>>> -        Collection<SearchResult> results =  
>>>>> (Collection<SearchResult>)
>>>>> pageContext.getAttribute( "searchresults",
>>>>> -
>>>>>                    PageContext.REQUEST_SCOPE );
>>>>> -        if( results == null )
>>>>> +        WikiActionBean actionBean =  
>>>>> WikiInterceptor.findActionBean(
>>>>> pageContext );
>>>>> +        if ( actionBean != null && actionBean instanceof
>>>>> SearchActionBean
>>>>> )
>>>>>       {
>>>>> -            return new ArrayList<SearchResult>();
>>>>> +            return ((SearchActionBean)actionBean).getResults();
>>>>>       }
>>>>> -        return results;
>>>>> +        return SearchActionBean.NO_RESULTS;
>>>>>   }
>>>>>
>>>>>   /**
>>>>>
>>>>> Modified:
>>>>>
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>> SearchResultsSizeTag.java
>>>>> URL:
>>>>>
>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsSizeTag.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>>
>>>>>
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> ==================================================================
>>>>> ---
>>>>>
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>> SearchResultsSizeTag.java
>>>>> (original)
>>>>> +++
>>>>>
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>> SearchResultsSizeTag.java
>>>>> Mon Jun  8 01:37:33 2009
>>>>> @@ -22,8 +22,8 @@
>>>>>
>>>>> import java.io.IOException;
>>>>> import java.util.Collection;
>>>>> -import javax.servlet.jsp.PageContext;
>>>>>
>>>>> +import org.apache.wiki.action.SearchActionBean;
>>>>> import org.apache.wiki.search.SearchResult;
>>>>>
>>>>> /**
>>>>> @@ -37,17 +37,14 @@
>>>>> {
>>>>>   private static final long serialVersionUID = 0L;
>>>>>
>>>>> -    @SuppressWarnings("unchecked")
>>>>>   public final int doWikiStartTag()
>>>>>       throws IOException
>>>>>   {
>>>>> -        Collection<SearchResult> list =
>>>>> (Collection 
>>>>> <SearchResult>)pageContext.getAttribute( "searchresults",
>>>>> -
>>>>> PageContext.REQUEST_SCOPE );
>>>>> -        if( list != null )
>>>>> +        if ( m_wikiActionBean != null && m_wikiActionBean  
>>>>> instanceof
>>>>> SearchActionBean )
>>>>>       {
>>>>> -            pageContext.getOut().print( list.size() );
>>>>> +            Collection<SearchResult> results =
>>>>> ((SearchActionBean)m_wikiActionBean).getResults();
>>>>> +            pageContext.getOut().print( results.size() );
>>>>>       }
>>>>> -
>>>>>       return SKIP_BODY;
>>>>>   }
>>>>> }
>>>>>
>>>>> Modified:
>>>>>
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>> SearchResultsTag.java
>>>>> URL:
>>>>>
>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsTag.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>>
>>>>>
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> = 
>>>>> ==================================================================
>>>>> ---
>>>>>
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>> SearchResultsTag.java
>>>>> (original)
>>>>> +++
>>>>>
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>> SearchResultsTag.java
>>>>> Mon Jun  8 01:37:33 2009
>>>>> @@ -21,10 +21,10 @@
>>>>> package org.apache.wiki.tags;
>>>>>
>>>>> import java.io.IOException;
>>>>> -import java.util.Collection;
>>>>> +
>>>>> import javax.servlet.jsp.PageContext;
>>>>>
>>>>> -import org.apache.wiki.search.SearchResult;
>>>>> +import org.apache.wiki.action.SearchActionBean;
>>>>>
>>>>> /**
>>>>> *  Includes the body content, if there are any search results.
>>>>> @@ -36,16 +36,16 @@
>>>>> {
>>>>>   private static final long serialVersionUID = 0L;
>>>>>
>>>>> -    @SuppressWarnings("unchecked")
>>>>>   public final int doWikiStartTag()
>>>>>       throws IOException
>>>>>   {
>>>>> -        Collection<SearchResult> list =
>>>>> (Collection 
>>>>> <SearchResult>)pageContext.getAttribute( "searchresults",
>>>>> -
>>>>> PageContext.REQUEST_SCOPE );
>>>>> -
>>>>> -        if( list != null )
>>>>> +        if ( m_wikiActionBean != null && m_wikiActionBean  
>>>>> instanceof
>>>>> SearchActionBean )
>>>>>       {
>>>>> -            return EVAL_BODY_INCLUDE;
>>>>> +            boolean emptyQuery =
>>>>> ((SearchActionBean)m_wikiActionBean).getQuery() == null;
>>>>> +            if ( !emptyQuery )
>>>>> +            {
>>>>> +                return EVAL_BODY_INCLUDE;
>>>>> +            }
>>>>>       }
>>>>>
>>>>>       String message = (String)pageContext.getAttribute( "err",
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>


Re: svn commit: r782495 - in /incubator/jspwiki/trunk/src: WebContent/ WebContent/scripts/ WebContent/templates/default/ java/org/apache/wiki/ java/org/apache/wiki/action/ java/org/apache/wiki/tags/

Posted by Dirk Frederickx <di...@gmail.com>.
Janne, Andrew,


Wiki.jsonrpc() is pretty much doing what you are  suggesting.
It just needs an update not to work anymore with JsonRPC but with hook-up
with Stripes' approach to ajax.

This shouldn't be to hard to figure out.
I'll check this out over the weekend, unless anyone is moving faster ;-)


dirk

On Mon, Jun 8, 2009 at 9:53 PM, Janne Jalkanen <ja...@ecyrd.com>wrote:

>
> Reminds me - the JS code used to call Ajax routines is disgustingly
> loathsome and makes my eyes bleed and my stomach retch.  Can we upgrade to a
> newer Mootools lib (1.2.2, I think) and switch to Request.JSON and create a
> JSONFactory or an extension for creating our AJAX requests?
>
> Something like wiki.json( "Search", "ajaxSearch", { param1 : value1, ... },
> callback(resultobj,resulttext) ); would be nice. This would construct the
> URL to SearchActionBean, method ajaxSearch, with the given params.
>
> /Janne
>
> On 8 Jun 2009, at 21:52, Andrew Jaquith wrote:
>
> It will fix this one -- but only after we've hooked it up to the
>> client JavaScript. Should not take long.
>>
>> On Mon, Jun 8, 2009 at 2:44 PM, Harry Metske<ha...@gmail.com>
>> wrote:
>>
>>> Andrew,
>>>
>>> should this patch have fixed
>>> https://issues.apache.org/jira/browse/JSPWIKI-510 (only for 3.0 of
>>> course) ?
>>>
>>> Harry
>>>
>>> 2009/6/8 <aj...@apache.org>
>>>
>>>
>>> Author: ajaquith
>>>> Date: Mon Jun  8 01:37:33 2009
>>>> New Revision: 782495
>>>>
>>>> URL: http://svn.apache.org/viewvc?rev=782495&view=rev
>>>> Log:
>>>> Search.jsp migrated to Stripes. SearchActionBean now provides searching
>>>> logic, including an ajaxSearch() method that filters results correctly
>>>> (this
>>>> is not hooked up to the client JavaScript yet, but it should be
>>>> straightforward to do). Still some i18n cleanup to do.
>>>>
>>>> Modified:
>>>>   incubator/jspwiki/trunk/src/WebContent/Search.jsp
>>>>   incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-common.js
>>>>
>>>> incubator/jspwiki/trunk/src/WebContent/templates/default/FindContent.jsp
>>>>   incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiContext.java
>>>>
>>>>
>>>>  incubator/jspwiki/trunk/src/java/org/apache/wiki/action/SearchActionBean.java
>>>>
>>>>
>>>>  incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IfNoSearchResultsTag.java
>>>>
>>>>
>>>>  incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultIteratorTag.java
>>>>
>>>>
>>>>  incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsSizeTag.java
>>>>
>>>>
>>>>  incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsTag.java
>>>>
>>>> Modified: incubator/jspwiki/trunk/src/WebContent/Search.jsp
>>>> URL:
>>>>
>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/WebContent/Search.jsp?rev=782495&r1=782494&r2=782495&view=diff
>>>>
>>>>
>>>> ==============================================================================
>>>> --- incubator/jspwiki/trunk/src/WebContent/Search.jsp (original)
>>>> +++ incubator/jspwiki/trunk/src/WebContent/Search.jsp Mon Jun  8
>>>> 01:37:33
>>>> 2009
>>>> @@ -18,108 +18,12 @@
>>>>    specific language governing permissions and limitations
>>>>    under the License.
>>>>  --%>
>>>> -<%@ page import="org.apache.wiki.log.Logger" %>
>>>> -<%@ page import="org.apache.wiki.log.LoggerFactory" %>
>>>> -<%@ page import="org.apache.wiki.*" %>
>>>> -<%@ page import="org.apache.wiki.auth.*" %>
>>>> -<%@ page import="org.apache.wiki.auth.permissions.*" %>
>>>> -<%@ page import="java.util.*" %>
>>>> +<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld" prefix="s"
>>>> %>
>>>>  <%@ page errorPage="/Error.jsp" %>
>>>> -<%@ page import="org.apache.wiki.search.*" %>
>>>> -<%@ taglib uri="http://jakarta.apache.org/jspwiki.tld" prefix="wiki"
>>>> %>
>>>> -<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld"
>>>> prefix="stripes" %>
>>>> -<%@ page import="org.apache.wiki.util.TextUtil" %>
>>>> -<%@ page import="org.apache.wiki.api.WikiPage" %>
>>>> -<stripes:useActionBean
>>>> beanclass="org.apache.wiki.action.SearchActionBean"
>>>> event="find" id="wikiActionBean" />
>>>> +<s:useActionBean beanclass="org.apache.wiki.action.SearchActionBean"
>>>> event="search" executeResolution="true" id="wikiActionBean" />
>>>> +<s:layout-render name="${templates['DefaultLayout.jsp']}">
>>>> +  <s:layout-component name="content">
>>>> +      <jsp:include page="${templates['FindContent.jsp']}" />
>>>> +  </s:layout-component>
>>>> +</s:layout-render>
>>>>
>>>> -<%!
>>>> -    Logger log = LoggerFactory.getLogger("JSPWikiSearch");
>>>> -%>
>>>> -
>>>> -<%
>>>> -    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
>>>> -    // Create wiki context and check for authorization
>>>> -    WikiContext wikiContext = wiki.createContext( request,
>>>> WikiContext.FIND );
>>>> -    String pagereq = wikiContext.getPage().getName();
>>>> -
>>>> -    // Get the search results
>>>> -    Collection list = null;
>>>> -    String query = request.getParameter( "query");
>>>> -    String go    = request.getParameter("go");
>>>> -
>>>> -    if( query != null )
>>>> -    {
>>>> -        log.info("Searching for string "+query);
>>>> -
>>>> -        try
>>>> -        {
>>>> -            list = wiki.findPages( query );
>>>> -
>>>> -            //
>>>> -            //  Filter down to only those that we actually have a
>>>> permission to view
>>>> -            //
>>>> -            AuthorizationManager mgr = wiki.getAuthorizationManager();
>>>> -
>>>> -            ArrayList filteredList = new ArrayList();
>>>> -
>>>> -            for( Iterator i = list.iterator(); i.hasNext(); )
>>>> -            {
>>>> -                SearchResult r = (SearchResult)i.next();
>>>> -
>>>> -                WikiPage p = r.getPage();
>>>> -
>>>> -                PagePermission pp = new PagePermission( p,
>>>> PagePermission.VIEW_ACTION );
>>>> -
>>>> -                try
>>>> -                {
>>>> -                    if( mgr.checkPermission(
>>>> wikiContext.getWikiSession(),
>>>> pp ) )
>>>> -                    {
>>>> -                        filteredList.add( r );
>>>> -                    }
>>>> -                }
>>>> -                catch( Exception e ) { log.error( "Searching for page
>>>> "+p,
>>>> e ); }
>>>> -            }
>>>> -
>>>> -            pageContext.setAttribute( "searchresults",
>>>> -                                      filteredList,
>>>> -                                      PageContext.REQUEST_SCOPE );
>>>> -        }
>>>> -        catch( Exception e )
>>>> -        {
>>>> -            wikiContext.getWikiSession().addMessage( e.getMessage() );
>>>> -        }
>>>> -
>>>> -        query = TextUtil.replaceEntities( query );
>>>> -
>>>> -        pageContext.setAttribute( "query",
>>>> -                                  query,
>>>> -                                  PageContext.REQUEST_SCOPE );
>>>> -
>>>> -        //
>>>> -        //  Did the user click on "go"?
>>>> -        //
>>>> -        if( go != null )
>>>> -        {
>>>> -            if( list != null && list.size() > 0 )
>>>> -            {
>>>> -                SearchResult sr = (SearchResult)
>>>> list.iterator().next();
>>>> -
>>>> -                WikiPage wikiPage = sr.getPage();
>>>> -
>>>> -                String url = wikiContext.getViewURL( wikiPage.getName()
>>>> );
>>>> -
>>>> -                response.sendRedirect( url );
>>>> -
>>>> -                return;
>>>> -            }
>>>> -        }
>>>> -    }
>>>> -
>>>> -    // Set the content type and include the response content
>>>> -    response.setContentType("text/html;
>>>> charset="+wiki.getContentEncoding() );
>>>> -    String contentPage = wiki.getTemplateManager().findJSP(
>>>> pageContext,
>>>> -
>>>>  wikiContext.getTemplate(),
>>>> -
>>>>  "ViewTemplate.jsp" );
>>>> -%><wiki:Include page="<%=contentPage%>" /><%
>>>> -    log.debug("SEARCH COMPLETE");
>>>> -%>
>>>>
>>>> Modified:
>>>> incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-common.js
>>>> URL:
>>>>
>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-common.js?rev=782495&r1=782494&r2=782495&view=diff
>>>>
>>>>
>>>> ==============================================================================
>>>> --- incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-common.js
>>>> (original)
>>>> +++ incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-common.js Mon
>>>> Jun  8 01:37:33 2009
>>>> @@ -931,9 +931,9 @@
>>>>                       if (option.value == match) option.selected = true;
>>>>               });
>>>>
>>>> -               new Ajax(Wiki.TemplateUrl+'AJAXSearch.jsp', {
>>>> -                       postBody: $('searchform2').toQueryString(),
>>>> -                       update: 'searchResult2',
>>>> +               new Ajax(Wiki.BasePath+'Search.action', {
>>>> +                       postBody:
>>>> "ajaxSearch=&"+$('searchform2').toQueryString(),
>>>> +                       update: 'searchResult2',
>>>>                       method: 'post',
>>>>                       onComplete: function() {
>>>>                               $('spin').hide();
>>>>
>>>> Modified:
>>>> incubator/jspwiki/trunk/src/WebContent/templates/default/FindContent.jsp
>>>> URL:
>>>>
>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/WebContent/templates/default/FindContent.jsp?rev=782495&r1=782494&r2=782495&view=diff
>>>>
>>>>
>>>> ==============================================================================
>>>> ---
>>>> incubator/jspwiki/trunk/src/WebContent/templates/default/FindContent.jsp
>>>> (original)
>>>> +++
>>>> incubator/jspwiki/trunk/src/WebContent/templates/default/FindContent.jsp
>>>> Mon
>>>> Jun  8 01:37:33 2009
>>>> @@ -27,24 +27,18 @@
>>>>  <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
>>>>  <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
>>>>  <%@ page import="javax.servlet.jsp.jstl.fmt.*" %>
>>>> -<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld"
>>>> prefix="stripes" %>
>>>> +<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld" prefix="s"
>>>> %>
>>>>
>>>>  <wiki:TabbedSection>
>>>>  <wiki:Tab id="findcontent" titleKey="find.tab" accesskey="s">
>>>>
>>>> -<form action="<wiki:Link format='url' jsp='Search.jsp'/>"
>>>> -       class="wikiform"
>>>> -          id="searchform2"
>>>> -         accept-charset="<wiki:ContentEncoding/>">
>>>> -
>>>> +<s:form beanclass="org.apache.wiki.action.SearchActionBean"
>>>> class="wikiform"
>>>> +    id="searchform2" acceptcharset="UTF-8">
>>>> +
>>>>  <h4><fmt:message key="find.input" /></h4>
>>>>  <p>
>>>> -    <input type="text"
>>>> -           name="query" id="query2"
>>>> -          value="<c:out value='${query}'/>"
>>>> -           size="32" />
>>>> -
>>>> -    <input type="checkbox" name="details" id="details" <c:if
>>>> test='${param.details == "on"}'>checked='checked'</c:if> />
>>>> +    <s:text name="query" id="query2" size="32" />
>>>> +    <s:checkbox name="details" id="details" />
>>>>    <fmt:message key="find.details" />
>>>>
>>>>    <select name="scope" id="scope">
>>>> @@ -55,16 +49,83 @@
>>>>      <option value="attachment:" <c:if test='${param.scope eq
>>>> "attachment:"}'>selected="selected"</c:if> ><fmt:message
>>>> key='find.scope.attach' /></option>
>>>>    </select>
>>>>
>>>> -       <input type="submit" name="ok" id="ok" value="<fmt:message
>>>> key="find.submit.find" />" />
>>>> -       <input type="submit" name="go" id="go" value="<fmt:message
>>>> key="find.submit.go" />" />
>>>> -    <input type="hidden" name="start" id="start" value="0" />
>>>> -    <input type="hidden" name="maxitems" id="maxitems" value="20" />
>>>> +    <s:submit name="search" id="ok" value="<fmt:message
>>>> key='find.submit.find' />" />
>>>> +    <s:submit name="go" id="go" value="<fmt:message
>>>> key='find.submit.go'
>>>> />" />
>>>> +    <s:hidden name="start" id="start" value="0" />
>>>> +    <s:hidden name="maxItems" id="maxitems" value="20" />
>>>>
>>>>    <span id="spin" class="spin"
>>>> style="position:absolute;display:none;"></span>
>>>>  </p>
>>>> -</form>
>>>> +</s:form>
>>>> +
>>>> +<div id="searchResult2">
>>>> +  <wiki:SearchResults>
>>>> +
>>>> +    <h4><fmt:message key="find.heading.results"><fmt:param><c:out
>>>> value="${wikiActionBean.query}" /></fmt:param></fmt:message></h4>
>>>> +    <p>
>>>> +      <fmt:message key="find.externalsearch" />
>>>> +      <a class="external" href="http://www.google.com/search?q=<c:out
>>>> value='${wikiActionBean.query}' />" title="Google Search '<c:out
>>>> value='${wikiActionBean.query}' />'" target="_blank">Google</a><img
>>>> class="outlink" src="images/out.png" alt="" />
>>>> +      |
>>>> +      <a class="external" href="
>>>> http://en.wikipedia.org/wiki/Special:Search?search=<c:out
>>>> value='${wikiActionBean.query}' />" title="Wikipedia Search '<c:out
>>>> value='${wikiActionBean.query}' />'" target="_blank">Wikipedia</a><img
>>>> class="outlink" src="images/out.png" alt="" />
>>>> +    </p>
>>>> +
>>>> +    <wiki:SetPagination start="${wikiActionBean.start}"
>>>> total="${wikiActionBean.resultsCount}" pagesize="20" maxlinks="9"
>>>> fmtkey="info.pagination" onclick="$('start').value=%s;
>>>> SearchBox.runfullsearch();" />
>>>> +
>>>> +    <div class="graphBars">
>>>> +      <div class="zebra-table">
>>>> +        <table class="wikitable">
>>>> +
>>>> +          <tr>
>>>> +             <th align="left"><fmt:message key="find.results.page"
>>>> /></th>
>>>> +             <th align="left"><fmt:message key="find.results.score"
>>>> /></th>
>>>> +          </tr>
>>>> +
>>>> +          <wiki:SearchResultIterator id="searchref"
>>>> start="${wikiActionBean.start}" maxItems="${wikiActionBean.maxItems}">
>>>> +          <tr>
>>>> +            <td><wiki:LinkTo><wiki:PageName/></wiki:LinkTo></td>
>>>> +            <td><span class="gBar"><%= searchref.getScore()
>>>> %></span></td>
>>>> +          </tr>
>>>> +
>>>> +          <c:if test="${wikiActionBean.details == 'true'}">
>>>> +  <%
>>>> +            String[] contexts = searchref.getContexts();
>>>> +            if( (contexts != null) && (contexts.length > 0) )
>>>> +            {
>>>> +  %>
>>>> +          <tr class="odd">
>>>> +            <td colspan="2">
>>>> +              <div class="fragment">
>>>> +  <%
>>>> +              for (int i = 0; i < contexts.length; i++)
>>>> +              {
>>>> +  %>
>>>> +                <%= (i > 0 ) ? "<span class='fragment_ellipsis'> ...
>>>> </span>" : ""  %>
>>>> +                <%= contexts[i]  %>
>>>> +  <%
>>>> +              }
>>>> +  %>
>>>> +               </div>
>>>> +             </td>
>>>> +           </tr>
>>>> +  <%
>>>> +            }
>>>> +  %>
>>>> +          </c:if><%-- details --%>
>>>> +        </wiki:SearchResultIterator>
>>>> +
>>>> +        <wiki:IfNoSearchResults>
>>>> +          <tr>
>>>> +            <td class="nosearchresult" colspan="2"><fmt:message
>>>> key="find.noresults" /></td>
>>>> +          </tr>
>>>> +        </wiki:IfNoSearchResults>
>>>> +
>>>> +        </table>
>>>> +      </div>
>>>> +    </div>
>>>> +    ${pagination}
>>>>
>>>> -<div id="searchResult2"><wiki:Include page="AJAXSearch.jsp" /></div>
>>>> +  </wiki:SearchResults>
>>>> +</div>
>>>>
>>>>  </wiki:Tab>
>>>>
>>>>
>>>> Modified:
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiContext.java
>>>> URL:
>>>>
>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiContext.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>
>>>>
>>>> ==============================================================================
>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiContext.java
>>>> (original)
>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiContext.java
>>>> Mon
>>>> Jun  8 01:37:33 2009
>>>> @@ -103,7 +103,7 @@
>>>>    public static final String    COMMENT  = HandlerInfo.getHandlerInfo(
>>>> EditActionBean.class, "comment" ).getRequestContext();
>>>>
>>>>    /** User is searching for content. */
>>>> -    public static final String    FIND     =
>>>> HandlerInfo.getHandlerInfo(
>>>> SearchActionBean.class, "find" ).getRequestContext();
>>>> +    public static final String    FIND     =
>>>> HandlerInfo.getHandlerInfo(
>>>> SearchActionBean.class, "search" ).getRequestContext();
>>>>
>>>>    /** User wishes to create a new group */
>>>>    public static final String    CREATE_GROUP =
>>>> HandlerInfo.getHandlerInfo( GroupActionBean.class, "create"
>>>> ).getRequestContext();
>>>>
>>>> Modified:
>>>>
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/action/SearchActionBean.java
>>>> URL:
>>>>
>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/action/SearchActionBean.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>
>>>>
>>>> ==============================================================================
>>>> ---
>>>>
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/action/SearchActionBean.java
>>>> (original)
>>>> +++
>>>>
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/action/SearchActionBean.java
>>>> Mon Jun  8 01:37:33 2009
>>>> @@ -21,18 +21,191 @@
>>>>
>>>>  package org.apache.wiki.action;
>>>>
>>>> -import org.apache.wiki.ui.stripes.WikiRequestContext;
>>>> +import java.util.ArrayList;
>>>> +import java.util.Collection;
>>>> +import java.util.Collections;
>>>> +import java.util.List;
>>>>
>>>>  import net.sourceforge.stripes.action.*;
>>>> +import net.sourceforge.stripes.ajax.JavaScriptResolution;
>>>> +
>>>> +import org.apache.wiki.WikiEngine;
>>>> +import org.apache.wiki.api.WikiPage;
>>>> +import org.apache.wiki.auth.AuthorizationManager;
>>>> +import org.apache.wiki.auth.permissions.PagePermission;
>>>> +import org.apache.wiki.log.Logger;
>>>> +import org.apache.wiki.log.LoggerFactory;
>>>> +import org.apache.wiki.search.SearchResult;
>>>> +import org.apache.wiki.ui.stripes.WikiRequestContext;
>>>>
>>>> +/**
>>>> + * Searches the WikiPage collection for a given wiki.
>>>> + */
>>>>  @UrlBinding( "/Search.jsp" )
>>>>  public class SearchActionBean extends AbstractActionBean
>>>>  {
>>>> +    private Logger log = LoggerFactory.getLogger("JSPWikiSearch");
>>>> +
>>>> +    public static final Collection<SearchResult> NO_RESULTS =
>>>> Collections.emptyList();
>>>> +
>>>> +    private Collection<SearchResult> m_results = NO_RESULTS;
>>>> +
>>>> +    private String m_query = null;
>>>> +
>>>> +    private int m_maxItems = 20;
>>>> +
>>>> +    private int m_start = 0;
>>>> +
>>>> +    private boolean m_details = false;
>>>> +
>>>> +    public boolean getDetails()
>>>> +    {
>>>> +        return m_details;
>>>> +    }
>>>> +
>>>> +    /**
>>>> +     * Sets the search results so that details for each result are
>>>> displayed.
>>>> +     * @param details whether details should be displayed
>>>> +     */
>>>> +    public void setDetails( boolean details )
>>>> +    {
>>>> +        m_details = details;
>>>> +    }
>>>> +
>>>> +    public int getMaxItems()
>>>> +    {
>>>> +        return m_maxItems;
>>>> +    }
>>>> +
>>>> +    public void setMaxItems( int maxItems )
>>>> +    {
>>>> +        m_maxItems = maxItems;
>>>> +    }
>>>> +
>>>> +    public int getStart()
>>>> +    {
>>>> +        return m_start;
>>>> +    }
>>>> +
>>>> +    public void setStart( int start )
>>>> +    {
>>>> +        m_start = start;
>>>> +    }
>>>> +
>>>> +    /**
>>>> +     * Returns the query string for the search.
>>>> +     *
>>>> +     * @return the query string
>>>> +     */
>>>> +    public String getQuery()
>>>> +    {
>>>> +        return m_query;
>>>> +    }
>>>> +
>>>> +    /**
>>>> +     * Returns the results of the search.
>>>> +     *
>>>> +     * @return the results
>>>> +     */
>>>> +    public Collection<SearchResult> getResults()
>>>> +    {
>>>> +        return m_results;
>>>> +    }
>>>> +
>>>> +    /**
>>>> +     * Returns the number of items returned by the current search.
>>>> +     * @return the number of items
>>>> +     */
>>>> +    public int getResultsCount()
>>>> +    {
>>>> +        return m_results.size();
>>>> +    }
>>>> +
>>>> +    /**
>>>> +     * Performs a search and returns the results as a list. For a given
>>>> WikiPage to
>>>> +     * be included in the results, the user must have permission to
>>>> view
>>>> it.
>>>> +     * If the underlying providers encounter an abnormal IOException or
>>>> other error,
>>>> +     * it will be added to the ActionBeanContext's validation messages
>>>> collection.
>>>> +     * @param query the query
>>>> +     * @return the results
>>>> +     */
>>>> +    private List<SearchResult> doSearch( String query )
>>>> +    {
>>>> +        log.info("Searching with query '"+ query + "'.");
>>>> +        WikiEngine engine = getContext().getEngine();
>>>> +        AuthorizationManager mgr = engine.getAuthorizationManager();
>>>> +
>>>> +        //
>>>> +        //  Filter down to only those that we actually have a
>>>> permission
>>>> to view
>>>> +        //
>>>> +        List<SearchResult> filteredResults = new
>>>> ArrayList<SearchResult>();
>>>> +        try
>>>> +        {
>>>> +            List<SearchResult> results = engine.findPages( query );
>>>> +            for( SearchResult result : results )
>>>> +            {
>>>> +                WikiPage page = result.getPage();
>>>> +                PagePermission permission = new PagePermission( page,
>>>> PagePermission.VIEW_ACTION );
>>>> +                try
>>>> +                {
>>>> +                    if( mgr.checkPermission(
>>>> getContext().getWikiSession(), permission ) )
>>>> +                    {
>>>> +                        filteredResults.add( result );
>>>> +                    }
>>>> +                }
>>>> +                catch( Exception e ) { log.error( "Searching for page "
>>>> +
>>>> page, e ); }
>>>> +            }
>>>> +        }
>>>> +        catch( Exception e )
>>>> +        {
>>>> +            log.debug( "Could not search using query '" + query + "'.",
>>>> e
>>>> );
>>>> +            Message message = new SimpleMessage( e.getMessage() );
>>>> +            getContext().getMessages().add( message );
>>>> +            e.printStackTrace();
>>>> +        }
>>>> +        return filteredResults;
>>>> +    }
>>>> +
>>>> +    /**
>>>> +     * Sets the query string for the search.
>>>> +     *
>>>> +     * @param query the query string
>>>> +     */
>>>> +    public void setQuery( String query )
>>>> +    {
>>>> +        m_query = query;
>>>> +    }
>>>> +
>>>> +    /**
>>>> +     * Searches the wiki using the query string set for this
>>>> +     * ActionBean. Search results are made available to callers via the
>>>> +     * {@link #getResults()} method (and EL expression
>>>> +     * <code>$wikiActionBean.results</code>).
>>>> +     *
>>>> +     * @return always returns a {@link ForwardResolution} to
>>>> +     *         <code>/Search.jsp</code>.
>>>> +     */
>>>>    @DefaultHandler
>>>> -    @HandlesEvent( "find" )
>>>> +    @HandlesEvent( "search" )
>>>>    @WikiRequestContext( "find" )
>>>> -    public Resolution view()
>>>> +    public Resolution search()
>>>>    {
>>>> +        m_results = m_query == null ? NO_RESULTS : doSearch( m_query );
>>>>        return new ForwardResolution( "/Search.jsp" );
>>>>    }
>>>> +
>>>> +    /**
>>>> +     * Using AJAX, searches a specified wiki space using the query
>>>> string
>>>> set for this
>>>> +     * ActionBean. Results are streamed back to the client as an array
>>>> of
>>>> JSON-encoded
>>>> +     * SearchResult objects.
>>>> +     *
>>>> +     * @return always returns a {@link JavaScriptResolution} containing
>>>> the
>>>> +     * results; this may be a zero-length array
>>>> +     */
>>>> +    @HandlesEvent( "ajaxSearch" )
>>>> +    public Resolution ajaxSearch()
>>>> +    {
>>>> +        m_results = m_query == null ? NO_RESULTS : doSearch( m_query );
>>>> +        return new JavaScriptResolution( m_results );
>>>> +    }
>>>>  }
>>>>
>>>> Modified:
>>>>
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IfNoSearchResultsTag.java
>>>> URL:
>>>>
>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IfNoSearchResultsTag.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>
>>>>
>>>> ==============================================================================
>>>> ---
>>>>
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IfNoSearchResultsTag.java
>>>> (original)
>>>> +++
>>>>
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IfNoSearchResultsTag.java
>>>> Mon Jun  8 01:37:33 2009
>>>> @@ -22,8 +22,8 @@
>>>>
>>>>  import java.io.IOException;
>>>>  import java.util.Collection;
>>>> -import javax.servlet.jsp.PageContext;
>>>>
>>>> +import org.apache.wiki.action.SearchActionBean;
>>>>  import org.apache.wiki.search.SearchResult;
>>>>
>>>>  /**
>>>> @@ -36,17 +36,18 @@
>>>>  {
>>>>    private static final long serialVersionUID = 0L;
>>>>
>>>> -    @SuppressWarnings("unchecked")
>>>>    public final int doWikiStartTag()
>>>>        throws IOException
>>>>    {
>>>> -        Collection<SearchResult> list =
>>>> (Collection<SearchResult>)pageContext.getAttribute( "searchresults",
>>>> -
>>>>  PageContext.REQUEST_SCOPE );
>>>> -        if( list == null || list.size() == 0 )
>>>> -        {
>>>> -            return EVAL_BODY_INCLUDE;
>>>> +        if ( m_wikiActionBean != null && m_wikiActionBean instanceof
>>>> SearchActionBean )
>>>> +        {
>>>> +            boolean emptyQuery =
>>>> ((SearchActionBean)m_wikiActionBean).getQuery() == null;
>>>> +            Collection<SearchResult> results =
>>>> ((SearchActionBean)m_wikiActionBean).getResults();
>>>> +            if ( emptyQuery || results.size() > 0 )
>>>> +            {
>>>> +                return SKIP_BODY;
>>>> +            }
>>>>        }
>>>> -
>>>> -        return SKIP_BODY;
>>>> +        return EVAL_BODY_INCLUDE;
>>>>    }
>>>>  }
>>>>
>>>> Modified:
>>>>
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultIteratorTag.java
>>>> URL:
>>>>
>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultIteratorTag.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>
>>>>
>>>> ==============================================================================
>>>> ---
>>>>
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultIteratorTag.java
>>>> (original)
>>>> +++
>>>>
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultIteratorTag.java
>>>> Mon Jun  8 01:37:33 2009
>>>> @@ -20,12 +20,12 @@
>>>>  */
>>>>  package org.apache.wiki.tags;
>>>>
>>>> -import java.util.ArrayList;
>>>>  import java.util.Collection;
>>>>
>>>> -import javax.servlet.jsp.PageContext;
>>>> -
>>>> +import org.apache.wiki.action.SearchActionBean;
>>>> +import org.apache.wiki.action.WikiActionBean;
>>>>  import org.apache.wiki.search.SearchResult;
>>>> +import org.apache.wiki.ui.stripes.WikiInterceptor;
>>>>
>>>>  /**
>>>>  * Iterator tag for the current search results, as identified by a
>>>> @@ -36,19 +36,17 @@
>>>>    private static final long serialVersionUID = 1L;
>>>>
>>>>    /**
>>>> -     * \ Returns the list of SearchResults to iterate over.
>>>> +     * Returns the list of SearchResults to iterate over.
>>>>     */
>>>>    @Override
>>>> -    @SuppressWarnings( "unchecked" )
>>>>    protected Collection<SearchResult> initItems()
>>>>    {
>>>> -        Collection<SearchResult> results = (Collection<SearchResult>)
>>>> pageContext.getAttribute( "searchresults",
>>>> -
>>>>                     PageContext.REQUEST_SCOPE );
>>>> -        if( results == null )
>>>> +        WikiActionBean actionBean = WikiInterceptor.findActionBean(
>>>> pageContext );
>>>> +        if ( actionBean != null && actionBean instanceof
>>>> SearchActionBean
>>>> )
>>>>        {
>>>> -            return new ArrayList<SearchResult>();
>>>> +            return ((SearchActionBean)actionBean).getResults();
>>>>        }
>>>> -        return results;
>>>> +        return SearchActionBean.NO_RESULTS;
>>>>    }
>>>>
>>>>    /**
>>>>
>>>> Modified:
>>>>
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsSizeTag.java
>>>> URL:
>>>>
>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsSizeTag.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>
>>>>
>>>> ==============================================================================
>>>> ---
>>>>
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsSizeTag.java
>>>> (original)
>>>> +++
>>>>
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsSizeTag.java
>>>> Mon Jun  8 01:37:33 2009
>>>> @@ -22,8 +22,8 @@
>>>>
>>>>  import java.io.IOException;
>>>>  import java.util.Collection;
>>>> -import javax.servlet.jsp.PageContext;
>>>>
>>>> +import org.apache.wiki.action.SearchActionBean;
>>>>  import org.apache.wiki.search.SearchResult;
>>>>
>>>>  /**
>>>> @@ -37,17 +37,14 @@
>>>>  {
>>>>    private static final long serialVersionUID = 0L;
>>>>
>>>> -    @SuppressWarnings("unchecked")
>>>>    public final int doWikiStartTag()
>>>>        throws IOException
>>>>    {
>>>> -        Collection<SearchResult> list =
>>>> (Collection<SearchResult>)pageContext.getAttribute( "searchresults",
>>>> -
>>>>  PageContext.REQUEST_SCOPE );
>>>> -        if( list != null )
>>>> +        if ( m_wikiActionBean != null && m_wikiActionBean instanceof
>>>> SearchActionBean )
>>>>        {
>>>> -            pageContext.getOut().print( list.size() );
>>>> +            Collection<SearchResult> results =
>>>> ((SearchActionBean)m_wikiActionBean).getResults();
>>>> +            pageContext.getOut().print( results.size() );
>>>>        }
>>>> -
>>>>        return SKIP_BODY;
>>>>    }
>>>>  }
>>>>
>>>> Modified:
>>>>
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsTag.java
>>>> URL:
>>>>
>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsTag.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>
>>>>
>>>> ==============================================================================
>>>> ---
>>>>
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsTag.java
>>>> (original)
>>>> +++
>>>>
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsTag.java
>>>> Mon Jun  8 01:37:33 2009
>>>> @@ -21,10 +21,10 @@
>>>>  package org.apache.wiki.tags;
>>>>
>>>>  import java.io.IOException;
>>>> -import java.util.Collection;
>>>> +
>>>>  import javax.servlet.jsp.PageContext;
>>>>
>>>> -import org.apache.wiki.search.SearchResult;
>>>> +import org.apache.wiki.action.SearchActionBean;
>>>>
>>>>  /**
>>>>  *  Includes the body content, if there are any search results.
>>>> @@ -36,16 +36,16 @@
>>>>  {
>>>>    private static final long serialVersionUID = 0L;
>>>>
>>>> -    @SuppressWarnings("unchecked")
>>>>    public final int doWikiStartTag()
>>>>        throws IOException
>>>>    {
>>>> -        Collection<SearchResult> list =
>>>> (Collection<SearchResult>)pageContext.getAttribute( "searchresults",
>>>> -
>>>>  PageContext.REQUEST_SCOPE );
>>>> -
>>>> -        if( list != null )
>>>> +        if ( m_wikiActionBean != null && m_wikiActionBean instanceof
>>>> SearchActionBean )
>>>>        {
>>>> -            return EVAL_BODY_INCLUDE;
>>>> +            boolean emptyQuery =
>>>> ((SearchActionBean)m_wikiActionBean).getQuery() == null;
>>>> +            if ( !emptyQuery )
>>>> +            {
>>>> +                return EVAL_BODY_INCLUDE;
>>>> +            }
>>>>        }
>>>>
>>>>        String message = (String)pageContext.getAttribute( "err",
>>>>
>>>>
>>>>
>>>>
>>>
>

Re: svn commit: r782495 - in /incubator/jspwiki/trunk/src: WebContent/ WebContent/scripts/ WebContent/templates/default/ java/org/apache/wiki/ java/org/apache/wiki/action/ java/org/apache/wiki/tags/

Posted by Janne Jalkanen <Ja...@ecyrd.com>.
Still, we should be able to get rid of it fairly easily, methinks.

/Janne

On Jun 12, 2009, at 16:44 , Harry Metske wrote:

> The large size of the HttpSession, that's definitely be a bug in
> MessAdmin.First,
> if I sum up all session sizes I would need a very large HeapSize,  
> while the
> JVM runs with only 256 MB.
> Secondly, I took a heapdump and had a look at it with IBM's HA, that  
> one
> tells me that the (deep) size of the JSONRPCBridge is about 70k,  
> which seems
> more reasonable (but still too large for large scale use).
>
> /Harry
>
> 2009/6/8 Harry Metske <ha...@gmail.com>
>
>> I had a look at the HttpSession size that JSPWiki creates after  
>> adding the
>> templates, and I probably must be doing something wrong.
>> The session size is an awful 5.7 MB (JSONRPCBridge being the  
>> largest by
>> far) :
>>
>> 5 attributes  Remove Attribute Attribute size Attribute name  
>> Attribute
>> value
>> 50 B javax.servlet.jsp.jstl.fmt.request.charset UTF-8
>> 1.07 KB prefs {Editor=plain, Skin=PlainVanilla, Orientation=LEFT,
>> TimeZone=Pacific/Midway, Locale=nl, SectionEditing=false,
>> TimeFormat=dd-MMM-yyyy HH:mm}
>> 6.92 KB templates {AJAXPreview.jsp=/templates/default/ 
>> AJAXPreview.jsp,
>> GroupContent.jsp=/templates/default/GroupContent.jsp,
>> PageActionsBottom.jsp=/templates/default/PageActionsBottom.jsp,
>> commonheader.jsp=/templates/default/commonheader.jsp,
>> jspwiki.css=/templates/default/jspwiki.css,
>> CommentContent.jsp=/templates/default/CommentContent.jsp,
>> Footer.jsp=/templates/default/Footer.jsp,
>> NewGroupContent.jsp=/templates/default/NewGroupContent.jsp,
>> WorkflowContent.jsp=/templates/default/WorkflowContent.jsp,
>> skins/=/templates/default/skins/,
>> PageActionsTop.jsp=/templates/default/PageActionsTop.jsp,
>> editors/=/templates/default/editors/,
>> EditGroupContent.jsp=/templates/default/EditGroupContent.jsp,
>> images/=/templates/default/images/,
>> AttachmentInfoTab.jsp=/templates/default/AttachmentInfoTab.jsp,
>> PageContent.jsp=/templates/default/PageContent.jsp,
>> AJAXCategories.jsp=/templates/default/AJAXCategories.jsp,
>> LostPasswordContent.jsp=/templates/default/LostPasswordContent.jsp,
>> PreviewContent.jsp=/templates/default/PreviewContent.jsp,
>> UserBox.jsp=/templates/default/UserBox.jsp,
>> admin/=/templates/default/admin/,
>> jspwiki_print.css=/templates/default/jspwiki_print.css,
>> GroupTab.jsp=/templates/default/GroupTab.jsp,
>> EditContent.jsp=/templates/default/EditContent.jsp,
>> DefaultLayout.jsp=/templates/default/DefaultLayout.jsp,
>> LoginContent.jsp=/templates/default/LoginContent.jsp,
>> SearchBox.jsp=/templates/default/SearchBox.jsp,
>> AttachmentTab.jsp=/templates/default/AttachmentTab.jsp,
>> FindContent.jsp=/templates/default/FindContent.jsp,
>> CreateProfileContent.jsp=/templates/default/CreateProfileContent.jsp,
>> PageTab.jsp=/templates/default/PageTab.jsp,
>> DisplayMessage.jsp=/templates/default/DisplayMessage.jsp,
>> PreferencesTab.jsp=/templates/default/PreferencesTab.jsp,
>> localheader.jsp=/templates/default/localheader.jsp,
>> EditTemplate.jsp=/templates/default/EditTemplate.jsp,
>> Header.jsp=/templates/default/Header.jsp,
>> ProfileTab.jsp=/templates/default/ProfileTab.jsp,
>> PageInfoTab.jsp=/templates/default/PageInfoTab.jsp,
>> DiffTab.jsp=/templates/default/DiffTab.jsp,
>> Favorites.jsp=/templates/default/Favorites.jsp,
>> ViewTemplate.jsp=/templates/default/ViewTemplate.jsp,
>> PreferencesContent.jsp=/templates/default/PreferencesContent.jsp,
>> DiffContent.jsp=/templates/default/DiffContent.jsp}
>> 5.72 MB JSONRPCBridge org.jabsorb.JSONRPCBridge@9ed91f
>> 156 B breadCrumbTrail [Recent Changes]
>> I'll see if I can get my hands on this if I have some more time  
>> this week.
>>
>> regards,
>> Harry
>>
>>
>>
>> 2009/6/8 Janne Jalkanen <ja...@ecyrd.com>
>>
>>
>>> Reminds me - the JS code used to call Ajax routines is disgustingly
>>> loathsome and makes my eyes bleed and my stomach retch.  Can we  
>>> upgrade to a
>>> newer Mootools lib (1.2.2, I think) and switch to Request.JSON and  
>>> create a
>>> JSONFactory or an extension for creating our AJAX requests?
>>>
>>> Something like wiki.json( "Search", "ajaxSearch", { param1 :  
>>> value1, ...
>>> }, callback(resultobj,resulttext) ); would be nice. This would  
>>> construct the
>>> URL to SearchActionBean, method ajaxSearch, with the given params.
>>>
>>> /Janne
>>>
>>>
>>> On 8 Jun 2009, at 21:52, Andrew Jaquith wrote:
>>>
>>> It will fix this one -- but only after we've hooked it up to the
>>>> client JavaScript. Should not take long.
>>>>
>>>> On Mon, Jun 8, 2009 at 2:44 PM, Harry  
>>>> Metske<ha...@gmail.com>
>>>> wrote:
>>>>
>>>>> Andrew,
>>>>>
>>>>> should this patch have fixed
>>>>> https://issues.apache.org/jira/browse/JSPWIKI-510 (only for 3.0 of
>>>>> course) ?
>>>>>
>>>>> Harry
>>>>>
>>>>> 2009/6/8 <aj...@apache.org>
>>>>>
>>>>> Author: ajaquith
>>>>>> Date: Mon Jun  8 01:37:33 2009
>>>>>> New Revision: 782495
>>>>>>
>>>>>> URL: http://svn.apache.org/viewvc?rev=782495&view=rev
>>>>>> Log:
>>>>>> Search.jsp migrated to Stripes. SearchActionBean now provides  
>>>>>> searching
>>>>>> logic, including an ajaxSearch() method that filters results  
>>>>>> correctly
>>>>>> (this
>>>>>> is not hooked up to the client JavaScript yet, but it should be
>>>>>> straightforward to do). Still some i18n cleanup to do.
>>>>>>
>>>>>> Modified:
>>>>>>  incubator/jspwiki/trunk/src/WebContent/Search.jsp
>>>>>>  incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-common.js
>>>>>>
>>>>>> incubator/jspwiki/trunk/src/WebContent/templates/default/ 
>>>>>> FindContent.jsp
>>>>>>  incubator/jspwiki/trunk/src/java/org/apache/wiki/ 
>>>>>> WikiContext.java
>>>>>>
>>>>>>
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/action/ 
>>>>>> SearchActionBean.java
>>>>>>
>>>>>>
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>> IfNoSearchResultsTag.java
>>>>>>
>>>>>>
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>> SearchResultIteratorTag.java
>>>>>>
>>>>>>
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>> SearchResultsSizeTag.java
>>>>>>
>>>>>>
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>> SearchResultsTag.java
>>>>>>
>>>>>> Modified: incubator/jspwiki/trunk/src/WebContent/Search.jsp
>>>>>> URL:
>>>>>>
>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/WebContent/Search.jsp?rev=782495&r1=782494&r2=782495&view=diff
>>>>>>
>>>>>>
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> =================================================================
>>>>>> --- incubator/jspwiki/trunk/src/WebContent/Search.jsp (original)
>>>>>> +++ incubator/jspwiki/trunk/src/WebContent/Search.jsp Mon Jun  8
>>>>>> 01:37:33
>>>>>> 2009
>>>>>> @@ -18,108 +18,12 @@
>>>>>>   specific language governing permissions and limitations
>>>>>>   under the License.
>>>>>> --%>
>>>>>> -<%@ page import="org.apache.wiki.log.Logger" %>
>>>>>> -<%@ page import="org.apache.wiki.log.LoggerFactory" %>
>>>>>> -<%@ page import="org.apache.wiki.*" %>
>>>>>> -<%@ page import="org.apache.wiki.auth.*" %>
>>>>>> -<%@ page import="org.apache.wiki.auth.permissions.*" %>
>>>>>> -<%@ page import="java.util.*" %>
>>>>>> +<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld"
>>>>>> prefix="s" %>
>>>>>> <%@ page errorPage="/Error.jsp" %>
>>>>>> -<%@ page import="org.apache.wiki.search.*" %>
>>>>>> -<%@ taglib uri="http://jakarta.apache.org/jspwiki.tld"  
>>>>>> prefix="wiki"
>>>>>> %>
>>>>>> -<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld"
>>>>>> prefix="stripes" %>
>>>>>> -<%@ page import="org.apache.wiki.util.TextUtil" %>
>>>>>> -<%@ page import="org.apache.wiki.api.WikiPage" %>
>>>>>> -<stripes:useActionBean
>>>>>> beanclass="org.apache.wiki.action.SearchActionBean"
>>>>>> event="find" id="wikiActionBean" />
>>>>>> +<s:useActionBean  
>>>>>> beanclass="org.apache.wiki.action.SearchActionBean"
>>>>>> event="search" executeResolution="true" id="wikiActionBean" />
>>>>>> +<s:layout-render name="${templates['DefaultLayout.jsp']}">
>>>>>> +  <s:layout-component name="content">
>>>>>> +      <jsp:include page="${templates['FindContent.jsp']}" />
>>>>>> +  </s:layout-component>
>>>>>> +</s:layout-render>
>>>>>>
>>>>>> -<%!
>>>>>> -    Logger log = LoggerFactory.getLogger("JSPWikiSearch");
>>>>>> -%>
>>>>>> -
>>>>>> -<%
>>>>>> -    WikiEngine wiki =  
>>>>>> WikiEngine.getInstance( getServletConfig() );
>>>>>> -    // Create wiki context and check for authorization
>>>>>> -    WikiContext wikiContext = wiki.createContext( request,
>>>>>> WikiContext.FIND );
>>>>>> -    String pagereq = wikiContext.getPage().getName();
>>>>>> -
>>>>>> -    // Get the search results
>>>>>> -    Collection list = null;
>>>>>> -    String query = request.getParameter( "query");
>>>>>> -    String go    = request.getParameter("go");
>>>>>> -
>>>>>> -    if( query != null )
>>>>>> -    {
>>>>>> -        log.info("Searching for string "+query);
>>>>>> -
>>>>>> -        try
>>>>>> -        {
>>>>>> -            list = wiki.findPages( query );
>>>>>> -
>>>>>> -            //
>>>>>> -            //  Filter down to only those that we actually  
>>>>>> have a
>>>>>> permission to view
>>>>>> -            //
>>>>>> -            AuthorizationManager mgr =  
>>>>>> wiki.getAuthorizationManager();
>>>>>> -
>>>>>> -            ArrayList filteredList = new ArrayList();
>>>>>> -
>>>>>> -            for( Iterator i = list.iterator(); i.hasNext(); )
>>>>>> -            {
>>>>>> -                SearchResult r = (SearchResult)i.next();
>>>>>> -
>>>>>> -                WikiPage p = r.getPage();
>>>>>> -
>>>>>> -                PagePermission pp = new PagePermission( p,
>>>>>> PagePermission.VIEW_ACTION );
>>>>>> -
>>>>>> -                try
>>>>>> -                {
>>>>>> -                    if( mgr.checkPermission(
>>>>>> wikiContext.getWikiSession(),
>>>>>> pp ) )
>>>>>> -                    {
>>>>>> -                        filteredList.add( r );
>>>>>> -                    }
>>>>>> -                }
>>>>>> -                catch( Exception e ) { log.error( "Searching  
>>>>>> for page
>>>>>> "+p,
>>>>>> e ); }
>>>>>> -            }
>>>>>> -
>>>>>> -            pageContext.setAttribute( "searchresults",
>>>>>> -                                      filteredList,
>>>>>> -                                       
>>>>>> PageContext.REQUEST_SCOPE );
>>>>>> -        }
>>>>>> -        catch( Exception e )
>>>>>> -        {
>>>>>> -             
>>>>>> wikiContext.getWikiSession().addMessage( e.getMessage() );
>>>>>> -        }
>>>>>> -
>>>>>> -        query = TextUtil.replaceEntities( query );
>>>>>> -
>>>>>> -        pageContext.setAttribute( "query",
>>>>>> -                                  query,
>>>>>> -                                  PageContext.REQUEST_SCOPE );
>>>>>> -
>>>>>> -        //
>>>>>> -        //  Did the user click on "go"?
>>>>>> -        //
>>>>>> -        if( go != null )
>>>>>> -        {
>>>>>> -            if( list != null && list.size() > 0 )
>>>>>> -            {
>>>>>> -                SearchResult sr = (SearchResult)
>>>>>> list.iterator().next();
>>>>>> -
>>>>>> -                WikiPage wikiPage = sr.getPage();
>>>>>> -
>>>>>> -                String url = wikiContext.getViewURL(
>>>>>> wikiPage.getName() );
>>>>>> -
>>>>>> -                response.sendRedirect( url );
>>>>>> -
>>>>>> -                return;
>>>>>> -            }
>>>>>> -        }
>>>>>> -    }
>>>>>> -
>>>>>> -    // Set the content type and include the response content
>>>>>> -    response.setContentType("text/html;
>>>>>> charset="+wiki.getContentEncoding() );
>>>>>> -    String contentPage = wiki.getTemplateManager().findJSP(
>>>>>> pageContext,
>>>>>> -
>>>>>> wikiContext.getTemplate(),
>>>>>> -
>>>>>> "ViewTemplate.jsp" );
>>>>>> -%><wiki:Include page="<%=contentPage%>" /><%
>>>>>> -    log.debug("SEARCH COMPLETE");
>>>>>> -%>
>>>>>>
>>>>>> Modified:
>>>>>> incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-common.js
>>>>>> URL:
>>>>>>
>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-common.js?rev=782495&r1=782494&r2=782495&view=diff
>>>>>>
>>>>>>
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> =================================================================
>>>>>> --- incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki- 
>>>>>> common.js
>>>>>> (original)
>>>>>> +++ incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki- 
>>>>>> common.js
>>>>>> Mon
>>>>>> Jun  8 01:37:33 2009
>>>>>> @@ -931,9 +931,9 @@
>>>>>>                      if (option.value == match) option.selected =
>>>>>> true;
>>>>>>              });
>>>>>>
>>>>>> -               new Ajax(Wiki.TemplateUrl+'AJAXSearch.jsp', {
>>>>>> -                       postBody: $ 
>>>>>> ('searchform2').toQueryString(),
>>>>>> -                       update: 'searchResult2',
>>>>>> +               new Ajax(Wiki.BasePath+'Search.action', {
>>>>>> +                       postBody:
>>>>>> "ajaxSearch=&"+$('searchform2').toQueryString(),
>>>>>> +                       update: 'searchResult2',
>>>>>>                      method: 'post',
>>>>>>                      onComplete: function() {
>>>>>>                              $('spin').hide();
>>>>>>
>>>>>> Modified:
>>>>>>
>>>>>> incubator/jspwiki/trunk/src/WebContent/templates/default/ 
>>>>>> FindContent.jsp
>>>>>> URL:
>>>>>>
>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/WebContent/templates/default/FindContent.jsp?rev=782495&r1=782494&r2=782495&view=diff
>>>>>>
>>>>>>
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> =================================================================
>>>>>> ---
>>>>>>
>>>>>> incubator/jspwiki/trunk/src/WebContent/templates/default/ 
>>>>>> FindContent.jsp
>>>>>> (original)
>>>>>> +++
>>>>>> incubator/jspwiki/trunk/src/WebContent/templates/default/ 
>>>>>> FindContent.jsp
>>>>>> Mon
>>>>>> Jun  8 01:37:33 2009
>>>>>> @@ -27,24 +27,18 @@
>>>>>> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
>>>>>> <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
>>>>>> <%@ page import="javax.servlet.jsp.jstl.fmt.*" %>
>>>>>> -<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld"
>>>>>> prefix="stripes" %>
>>>>>> +<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld"
>>>>>> prefix="s" %>
>>>>>>
>>>>>> <wiki:TabbedSection>
>>>>>> <wiki:Tab id="findcontent" titleKey="find.tab" accesskey="s">
>>>>>>
>>>>>> -<form action="<wiki:Link format='url' jsp='Search.jsp'/>"
>>>>>> -       class="wikiform"
>>>>>> -          id="searchform2"
>>>>>> -         accept-charset="<wiki:ContentEncoding/>">
>>>>>> -
>>>>>> +<s:form beanclass="org.apache.wiki.action.SearchActionBean"
>>>>>> class="wikiform"
>>>>>> +    id="searchform2" acceptcharset="UTF-8">
>>>>>> +
>>>>>> <h4><fmt:message key="find.input" /></h4>
>>>>>> <p>
>>>>>> -    <input type="text"
>>>>>> -           name="query" id="query2"
>>>>>> -          value="<c:out value='${query}'/>"
>>>>>> -           size="32" />
>>>>>> -
>>>>>> -    <input type="checkbox" name="details" id="details" <c:if
>>>>>> test='${param.details == "on"}'>checked='checked'</c:if> />
>>>>>> +    <s:text name="query" id="query2" size="32" />
>>>>>> +    <s:checkbox name="details" id="details" />
>>>>>>   <fmt:message key="find.details" />
>>>>>>
>>>>>>   <select name="scope" id="scope">
>>>>>> @@ -55,16 +49,83 @@
>>>>>>     <option value="attachment:" <c:if test='${param.scope eq
>>>>>> "attachment:"}'>selected="selected"</c:if> ><fmt:message
>>>>>> key='find.scope.attach' /></option>
>>>>>>   </select>
>>>>>>
>>>>>> -       <input type="submit" name="ok" id="ok"  
>>>>>> value="<fmt:message
>>>>>> key="find.submit.find" />" />
>>>>>> -       <input type="submit" name="go" id="go"  
>>>>>> value="<fmt:message
>>>>>> key="find.submit.go" />" />
>>>>>> -    <input type="hidden" name="start" id="start" value="0" />
>>>>>> -    <input type="hidden" name="maxitems" id="maxitems"  
>>>>>> value="20" />
>>>>>> +    <s:submit name="search" id="ok" value="<fmt:message
>>>>>> key='find.submit.find' />" />
>>>>>> +    <s:submit name="go" id="go" value="<fmt:message
>>>>>> key='find.submit.go'
>>>>>> />" />
>>>>>> +    <s:hidden name="start" id="start" value="0" />
>>>>>> +    <s:hidden name="maxItems" id="maxitems" value="20" />
>>>>>>
>>>>>>   <span id="spin" class="spin"
>>>>>> style="position:absolute;display:none;"></span>
>>>>>> </p>
>>>>>> -</form>
>>>>>> +</s:form>
>>>>>> +
>>>>>> +<div id="searchResult2">
>>>>>> +  <wiki:SearchResults>
>>>>>> +
>>>>>> +    <h4><fmt:message  
>>>>>> key="find.heading.results"><fmt:param><c:out
>>>>>> value="${wikiActionBean.query}" /></fmt:param></fmt:message></h4>
>>>>>> +    <p>
>>>>>> +      <fmt:message key="find.externalsearch" />
>>>>>> +      <a class="external" href="http://www.google.com/search? 
>>>>>> q=<c:out
>>>>>> value='${wikiActionBean.query}' />" title="Google Search '<c:out
>>>>>> value='${wikiActionBean.query}' />'" target="_blank">Google</ 
>>>>>> a><img
>>>>>> class="outlink" src="images/out.png" alt="" />
>>>>>> +      |
>>>>>> +      <a class="external" href="
>>>>>> http://en.wikipedia.org/wiki/Special:Search?search=<c:out
>>>>>> value='${wikiActionBean.query}' />" title="Wikipedia Search  
>>>>>> '<c:out
>>>>>> value='${wikiActionBean.query}' />'" target="_blank">Wikipedia</ 
>>>>>> a><img
>>>>>> class="outlink" src="images/out.png" alt="" />
>>>>>> +    </p>
>>>>>> +
>>>>>> +    <wiki:SetPagination start="${wikiActionBean.start}"
>>>>>> total="${wikiActionBean.resultsCount}" pagesize="20" maxlinks="9"
>>>>>> fmtkey="info.pagination" onclick="$('start').value=%s;
>>>>>> SearchBox.runfullsearch();" />
>>>>>> +
>>>>>> +    <div class="graphBars">
>>>>>> +      <div class="zebra-table">
>>>>>> +        <table class="wikitable">
>>>>>> +
>>>>>> +          <tr>
>>>>>> +             <th align="left"><fmt:message  
>>>>>> key="find.results.page"
>>>>>> /></th>
>>>>>> +             <th align="left"><fmt:message  
>>>>>> key="find.results.score"
>>>>>> /></th>
>>>>>> +          </tr>
>>>>>> +
>>>>>> +          <wiki:SearchResultIterator id="searchref"
>>>>>> start="${wikiActionBean.start}" maxItems="$ 
>>>>>> {wikiActionBean.maxItems}">
>>>>>> +          <tr>
>>>>>> +            <td><wiki:LinkTo><wiki:PageName/></wiki:LinkTo></td>
>>>>>> +            <td><span class="gBar"><%= searchref.getScore()
>>>>>> %></span></td>
>>>>>> +          </tr>
>>>>>> +
>>>>>> +          <c:if test="${wikiActionBean.details == 'true'}">
>>>>>> +  <%
>>>>>> +            String[] contexts = searchref.getContexts();
>>>>>> +            if( (contexts != null) && (contexts.length > 0) )
>>>>>> +            {
>>>>>> +  %>
>>>>>> +          <tr class="odd">
>>>>>> +            <td colspan="2">
>>>>>> +              <div class="fragment">
>>>>>> +  <%
>>>>>> +              for (int i = 0; i < contexts.length; i++)
>>>>>> +              {
>>>>>> +  %>
>>>>>> +                <%= (i > 0 ) ? "<span  
>>>>>> class='fragment_ellipsis'> ...
>>>>>> </span>" : ""  %>
>>>>>> +                <%= contexts[i]  %>
>>>>>> +  <%
>>>>>> +              }
>>>>>> +  %>
>>>>>> +               </div>
>>>>>> +             </td>
>>>>>> +           </tr>
>>>>>> +  <%
>>>>>> +            }
>>>>>> +  %>
>>>>>> +          </c:if><%-- details --%>
>>>>>> +        </wiki:SearchResultIterator>
>>>>>> +
>>>>>> +        <wiki:IfNoSearchResults>
>>>>>> +          <tr>
>>>>>> +            <td class="nosearchresult" colspan="2"><fmt:message
>>>>>> key="find.noresults" /></td>
>>>>>> +          </tr>
>>>>>> +        </wiki:IfNoSearchResults>
>>>>>> +
>>>>>> +        </table>
>>>>>> +      </div>
>>>>>> +    </div>
>>>>>> +    ${pagination}
>>>>>>
>>>>>> -<div id="searchResult2"><wiki:Include page="AJAXSearch.jsp" / 
>>>>>> ></div>
>>>>>> +  </wiki:SearchResults>
>>>>>> +</div>
>>>>>>
>>>>>> </wiki:Tab>
>>>>>>
>>>>>>
>>>>>> Modified:
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiContext.java
>>>>>> URL:
>>>>>>
>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiContext.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>>>
>>>>>>
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> =================================================================
>>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/ 
>>>>>> WikiContext.java
>>>>>> (original)
>>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/ 
>>>>>> WikiContext.java
>>>>>> Mon
>>>>>> Jun  8 01:37:33 2009
>>>>>> @@ -103,7 +103,7 @@
>>>>>>   public static final String    COMMENT  =  
>>>>>> HandlerInfo.getHandlerInfo(
>>>>>> EditActionBean.class, "comment" ).getRequestContext();
>>>>>>
>>>>>>   /** User is searching for content. */
>>>>>> -    public static final String    FIND     =
>>>>>> HandlerInfo.getHandlerInfo(
>>>>>> SearchActionBean.class, "find" ).getRequestContext();
>>>>>> +    public static final String    FIND     =
>>>>>> HandlerInfo.getHandlerInfo(
>>>>>> SearchActionBean.class, "search" ).getRequestContext();
>>>>>>
>>>>>>   /** User wishes to create a new group */
>>>>>>   public static final String    CREATE_GROUP =
>>>>>> HandlerInfo.getHandlerInfo( GroupActionBean.class, "create"
>>>>>> ).getRequestContext();
>>>>>>
>>>>>> Modified:
>>>>>>
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/action/ 
>>>>>> SearchActionBean.java
>>>>>> URL:
>>>>>>
>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/action/SearchActionBean.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>>>
>>>>>>
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> =================================================================
>>>>>> ---
>>>>>>
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/action/ 
>>>>>> SearchActionBean.java
>>>>>> (original)
>>>>>> +++
>>>>>>
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/action/ 
>>>>>> SearchActionBean.java
>>>>>> Mon Jun  8 01:37:33 2009
>>>>>> @@ -21,18 +21,191 @@
>>>>>>
>>>>>> package org.apache.wiki.action;
>>>>>>
>>>>>> -import org.apache.wiki.ui.stripes.WikiRequestContext;
>>>>>> +import java.util.ArrayList;
>>>>>> +import java.util.Collection;
>>>>>> +import java.util.Collections;
>>>>>> +import java.util.List;
>>>>>>
>>>>>> import net.sourceforge.stripes.action.*;
>>>>>> +import net.sourceforge.stripes.ajax.JavaScriptResolution;
>>>>>> +
>>>>>> +import org.apache.wiki.WikiEngine;
>>>>>> +import org.apache.wiki.api.WikiPage;
>>>>>> +import org.apache.wiki.auth.AuthorizationManager;
>>>>>> +import org.apache.wiki.auth.permissions.PagePermission;
>>>>>> +import org.apache.wiki.log.Logger;
>>>>>> +import org.apache.wiki.log.LoggerFactory;
>>>>>> +import org.apache.wiki.search.SearchResult;
>>>>>> +import org.apache.wiki.ui.stripes.WikiRequestContext;
>>>>>>
>>>>>> +/**
>>>>>> + * Searches the WikiPage collection for a given wiki.
>>>>>> + */
>>>>>> @UrlBinding( "/Search.jsp" )
>>>>>> public class SearchActionBean extends AbstractActionBean
>>>>>> {
>>>>>> +    private Logger log =  
>>>>>> LoggerFactory.getLogger("JSPWikiSearch");
>>>>>> +
>>>>>> +    public static final Collection<SearchResult> NO_RESULTS =
>>>>>> Collections.emptyList();
>>>>>> +
>>>>>> +    private Collection<SearchResult> m_results = NO_RESULTS;
>>>>>> +
>>>>>> +    private String m_query = null;
>>>>>> +
>>>>>> +    private int m_maxItems = 20;
>>>>>> +
>>>>>> +    private int m_start = 0;
>>>>>> +
>>>>>> +    private boolean m_details = false;
>>>>>> +
>>>>>> +    public boolean getDetails()
>>>>>> +    {
>>>>>> +        return m_details;
>>>>>> +    }
>>>>>> +
>>>>>> +    /**
>>>>>> +     * Sets the search results so that details for each result  
>>>>>> are
>>>>>> displayed.
>>>>>> +     * @param details whether details should be displayed
>>>>>> +     */
>>>>>> +    public void setDetails( boolean details )
>>>>>> +    {
>>>>>> +        m_details = details;
>>>>>> +    }
>>>>>> +
>>>>>> +    public int getMaxItems()
>>>>>> +    {
>>>>>> +        return m_maxItems;
>>>>>> +    }
>>>>>> +
>>>>>> +    public void setMaxItems( int maxItems )
>>>>>> +    {
>>>>>> +        m_maxItems = maxItems;
>>>>>> +    }
>>>>>> +
>>>>>> +    public int getStart()
>>>>>> +    {
>>>>>> +        return m_start;
>>>>>> +    }
>>>>>> +
>>>>>> +    public void setStart( int start )
>>>>>> +    {
>>>>>> +        m_start = start;
>>>>>> +    }
>>>>>> +
>>>>>> +    /**
>>>>>> +     * Returns the query string for the search.
>>>>>> +     *
>>>>>> +     * @return the query string
>>>>>> +     */
>>>>>> +    public String getQuery()
>>>>>> +    {
>>>>>> +        return m_query;
>>>>>> +    }
>>>>>> +
>>>>>> +    /**
>>>>>> +     * Returns the results of the search.
>>>>>> +     *
>>>>>> +     * @return the results
>>>>>> +     */
>>>>>> +    public Collection<SearchResult> getResults()
>>>>>> +    {
>>>>>> +        return m_results;
>>>>>> +    }
>>>>>> +
>>>>>> +    /**
>>>>>> +     * Returns the number of items returned by the current  
>>>>>> search.
>>>>>> +     * @return the number of items
>>>>>> +     */
>>>>>> +    public int getResultsCount()
>>>>>> +    {
>>>>>> +        return m_results.size();
>>>>>> +    }
>>>>>> +
>>>>>> +    /**
>>>>>> +     * Performs a search and returns the results as a list.  
>>>>>> For a
>>>>>> given
>>>>>> WikiPage to
>>>>>> +     * be included in the results, the user must have  
>>>>>> permission to
>>>>>> view
>>>>>> it.
>>>>>> +     * If the underlying providers encounter an abnormal  
>>>>>> IOException
>>>>>> or
>>>>>> other error,
>>>>>> +     * it will be added to the ActionBeanContext's validation  
>>>>>> messages
>>>>>> collection.
>>>>>> +     * @param query the query
>>>>>> +     * @return the results
>>>>>> +     */
>>>>>> +    private List<SearchResult> doSearch( String query )
>>>>>> +    {
>>>>>> +        log.info("Searching with query '"+ query + "'.");
>>>>>> +        WikiEngine engine = getContext().getEngine();
>>>>>> +        AuthorizationManager mgr =  
>>>>>> engine.getAuthorizationManager();
>>>>>> +
>>>>>> +        //
>>>>>> +        //  Filter down to only those that we actually have a
>>>>>> permission
>>>>>> to view
>>>>>> +        //
>>>>>> +        List<SearchResult> filteredResults = new
>>>>>> ArrayList<SearchResult>();
>>>>>> +        try
>>>>>> +        {
>>>>>> +            List<SearchResult> results =  
>>>>>> engine.findPages( query );
>>>>>> +            for( SearchResult result : results )
>>>>>> +            {
>>>>>> +                WikiPage page = result.getPage();
>>>>>> +                PagePermission permission = new  
>>>>>> PagePermission( page,
>>>>>> PagePermission.VIEW_ACTION );
>>>>>> +                try
>>>>>> +                {
>>>>>> +                    if( mgr.checkPermission(
>>>>>> getContext().getWikiSession(), permission ) )
>>>>>> +                    {
>>>>>> +                        filteredResults.add( result );
>>>>>> +                    }
>>>>>> +                }
>>>>>> +                catch( Exception e ) { log.error( "Searching  
>>>>>> for page
>>>>>> " +
>>>>>> page, e ); }
>>>>>> +            }
>>>>>> +        }
>>>>>> +        catch( Exception e )
>>>>>> +        {
>>>>>> +            log.debug( "Could not search using query '" +  
>>>>>> query +
>>>>>> "'.", e
>>>>>> );
>>>>>> +            Message message = new  
>>>>>> SimpleMessage( e.getMessage() );
>>>>>> +            getContext().getMessages().add( message );
>>>>>> +            e.printStackTrace();
>>>>>> +        }
>>>>>> +        return filteredResults;
>>>>>> +    }
>>>>>> +
>>>>>> +    /**
>>>>>> +     * Sets the query string for the search.
>>>>>> +     *
>>>>>> +     * @param query the query string
>>>>>> +     */
>>>>>> +    public void setQuery( String query )
>>>>>> +    {
>>>>>> +        m_query = query;
>>>>>> +    }
>>>>>> +
>>>>>> +    /**
>>>>>> +     * Searches the wiki using the query string set for this
>>>>>> +     * ActionBean. Search results are made available to  
>>>>>> callers via
>>>>>> the
>>>>>> +     * {@link #getResults()} method (and EL expression
>>>>>> +     * <code>$wikiActionBean.results</code>).
>>>>>> +     *
>>>>>> +     * @return always returns a {@link ForwardResolution} to
>>>>>> +     *         <code>/Search.jsp</code>.
>>>>>> +     */
>>>>>>   @DefaultHandler
>>>>>> -    @HandlesEvent( "find" )
>>>>>> +    @HandlesEvent( "search" )
>>>>>>   @WikiRequestContext( "find" )
>>>>>> -    public Resolution view()
>>>>>> +    public Resolution search()
>>>>>>   {
>>>>>> +        m_results = m_query == null ? NO_RESULTS :  
>>>>>> doSearch( m_query
>>>>>> );
>>>>>>       return new ForwardResolution( "/Search.jsp" );
>>>>>>   }
>>>>>> +
>>>>>> +    /**
>>>>>> +     * Using AJAX, searches a specified wiki space using the  
>>>>>> query
>>>>>> string
>>>>>> set for this
>>>>>> +     * ActionBean. Results are streamed back to the client as  
>>>>>> an array
>>>>>> of
>>>>>> JSON-encoded
>>>>>> +     * SearchResult objects.
>>>>>> +     *
>>>>>> +     * @return always returns a {@link JavaScriptResolution}
>>>>>> containing
>>>>>> the
>>>>>> +     * results; this may be a zero-length array
>>>>>> +     */
>>>>>> +    @HandlesEvent( "ajaxSearch" )
>>>>>> +    public Resolution ajaxSearch()
>>>>>> +    {
>>>>>> +        m_results = m_query == null ? NO_RESULTS :  
>>>>>> doSearch( m_query
>>>>>> );
>>>>>> +        return new JavaScriptResolution( m_results );
>>>>>> +    }
>>>>>> }
>>>>>>
>>>>>> Modified:
>>>>>>
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>> IfNoSearchResultsTag.java
>>>>>> URL:
>>>>>>
>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IfNoSearchResultsTag.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>>>
>>>>>>
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> =================================================================
>>>>>> ---
>>>>>>
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>> IfNoSearchResultsTag.java
>>>>>> (original)
>>>>>> +++
>>>>>>
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>> IfNoSearchResultsTag.java
>>>>>> Mon Jun  8 01:37:33 2009
>>>>>> @@ -22,8 +22,8 @@
>>>>>>
>>>>>> import java.io.IOException;
>>>>>> import java.util.Collection;
>>>>>> -import javax.servlet.jsp.PageContext;
>>>>>>
>>>>>> +import org.apache.wiki.action.SearchActionBean;
>>>>>> import org.apache.wiki.search.SearchResult;
>>>>>>
>>>>>> /**
>>>>>> @@ -36,17 +36,18 @@
>>>>>> {
>>>>>>   private static final long serialVersionUID = 0L;
>>>>>>
>>>>>> -    @SuppressWarnings("unchecked")
>>>>>>   public final int doWikiStartTag()
>>>>>>       throws IOException
>>>>>>   {
>>>>>> -        Collection<SearchResult> list =
>>>>>> (Collection 
>>>>>> <SearchResult>)pageContext.getAttribute( "searchresults",
>>>>>> -
>>>>>> PageContext.REQUEST_SCOPE );
>>>>>> -        if( list == null || list.size() == 0 )
>>>>>> -        {
>>>>>> -            return EVAL_BODY_INCLUDE;
>>>>>> +        if ( m_wikiActionBean != null && m_wikiActionBean  
>>>>>> instanceof
>>>>>> SearchActionBean )
>>>>>> +        {
>>>>>> +            boolean emptyQuery =
>>>>>> ((SearchActionBean)m_wikiActionBean).getQuery() == null;
>>>>>> +            Collection<SearchResult> results =
>>>>>> ((SearchActionBean)m_wikiActionBean).getResults();
>>>>>> +            if ( emptyQuery || results.size() > 0 )
>>>>>> +            {
>>>>>> +                return SKIP_BODY;
>>>>>> +            }
>>>>>>       }
>>>>>> -
>>>>>> -        return SKIP_BODY;
>>>>>> +        return EVAL_BODY_INCLUDE;
>>>>>>   }
>>>>>> }
>>>>>>
>>>>>> Modified:
>>>>>>
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>> SearchResultIteratorTag.java
>>>>>> URL:
>>>>>>
>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultIteratorTag.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>>>
>>>>>>
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> =================================================================
>>>>>> ---
>>>>>>
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>> SearchResultIteratorTag.java
>>>>>> (original)
>>>>>> +++
>>>>>>
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>> SearchResultIteratorTag.java
>>>>>> Mon Jun  8 01:37:33 2009
>>>>>> @@ -20,12 +20,12 @@
>>>>>> */
>>>>>> package org.apache.wiki.tags;
>>>>>>
>>>>>> -import java.util.ArrayList;
>>>>>> import java.util.Collection;
>>>>>>
>>>>>> -import javax.servlet.jsp.PageContext;
>>>>>> -
>>>>>> +import org.apache.wiki.action.SearchActionBean;
>>>>>> +import org.apache.wiki.action.WikiActionBean;
>>>>>> import org.apache.wiki.search.SearchResult;
>>>>>> +import org.apache.wiki.ui.stripes.WikiInterceptor;
>>>>>>
>>>>>> /**
>>>>>> * Iterator tag for the current search results, as identified by a
>>>>>> @@ -36,19 +36,17 @@
>>>>>>   private static final long serialVersionUID = 1L;
>>>>>>
>>>>>>   /**
>>>>>> -     * \ Returns the list of SearchResults to iterate over.
>>>>>> +     * Returns the list of SearchResults to iterate over.
>>>>>>    */
>>>>>>   @Override
>>>>>> -    @SuppressWarnings( "unchecked" )
>>>>>>   protected Collection<SearchResult> initItems()
>>>>>>   {
>>>>>> -        Collection<SearchResult> results =  
>>>>>> (Collection<SearchResult>)
>>>>>> pageContext.getAttribute( "searchresults",
>>>>>> -
>>>>>>                    PageContext.REQUEST_SCOPE );
>>>>>> -        if( results == null )
>>>>>> +        WikiActionBean actionBean =  
>>>>>> WikiInterceptor.findActionBean(
>>>>>> pageContext );
>>>>>> +        if ( actionBean != null && actionBean instanceof
>>>>>> SearchActionBean
>>>>>> )
>>>>>>       {
>>>>>> -            return new ArrayList<SearchResult>();
>>>>>> +            return ((SearchActionBean)actionBean).getResults();
>>>>>>       }
>>>>>> -        return results;
>>>>>> +        return SearchActionBean.NO_RESULTS;
>>>>>>   }
>>>>>>
>>>>>>   /**
>>>>>>
>>>>>> Modified:
>>>>>>
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>> SearchResultsSizeTag.java
>>>>>> URL:
>>>>>>
>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsSizeTag.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>>>
>>>>>>
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> =================================================================
>>>>>> ---
>>>>>>
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>> SearchResultsSizeTag.java
>>>>>> (original)
>>>>>> +++
>>>>>>
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>> SearchResultsSizeTag.java
>>>>>> Mon Jun  8 01:37:33 2009
>>>>>> @@ -22,8 +22,8 @@
>>>>>>
>>>>>> import java.io.IOException;
>>>>>> import java.util.Collection;
>>>>>> -import javax.servlet.jsp.PageContext;
>>>>>>
>>>>>> +import org.apache.wiki.action.SearchActionBean;
>>>>>> import org.apache.wiki.search.SearchResult;
>>>>>>
>>>>>> /**
>>>>>> @@ -37,17 +37,14 @@
>>>>>> {
>>>>>>   private static final long serialVersionUID = 0L;
>>>>>>
>>>>>> -    @SuppressWarnings("unchecked")
>>>>>>   public final int doWikiStartTag()
>>>>>>       throws IOException
>>>>>>   {
>>>>>> -        Collection<SearchResult> list =
>>>>>> (Collection 
>>>>>> <SearchResult>)pageContext.getAttribute( "searchresults",
>>>>>> -
>>>>>> PageContext.REQUEST_SCOPE );
>>>>>> -        if( list != null )
>>>>>> +        if ( m_wikiActionBean != null && m_wikiActionBean  
>>>>>> instanceof
>>>>>> SearchActionBean )
>>>>>>       {
>>>>>> -            pageContext.getOut().print( list.size() );
>>>>>> +            Collection<SearchResult> results =
>>>>>> ((SearchActionBean)m_wikiActionBean).getResults();
>>>>>> +            pageContext.getOut().print( results.size() );
>>>>>>       }
>>>>>> -
>>>>>>       return SKIP_BODY;
>>>>>>   }
>>>>>> }
>>>>>>
>>>>>> Modified:
>>>>>>
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>> SearchResultsTag.java
>>>>>> URL:
>>>>>>
>>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsTag.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>>>
>>>>>>
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> = 
>>>>>> =================================================================
>>>>>> ---
>>>>>>
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>> SearchResultsTag.java
>>>>>> (original)
>>>>>> +++
>>>>>>
>>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>>>>> SearchResultsTag.java
>>>>>> Mon Jun  8 01:37:33 2009
>>>>>> @@ -21,10 +21,10 @@
>>>>>> package org.apache.wiki.tags;
>>>>>>
>>>>>> import java.io.IOException;
>>>>>> -import java.util.Collection;
>>>>>> +
>>>>>> import javax.servlet.jsp.PageContext;
>>>>>>
>>>>>> -import org.apache.wiki.search.SearchResult;
>>>>>> +import org.apache.wiki.action.SearchActionBean;
>>>>>>
>>>>>> /**
>>>>>> *  Includes the body content, if there are any search results.
>>>>>> @@ -36,16 +36,16 @@
>>>>>> {
>>>>>>   private static final long serialVersionUID = 0L;
>>>>>>
>>>>>> -    @SuppressWarnings("unchecked")
>>>>>>   public final int doWikiStartTag()
>>>>>>       throws IOException
>>>>>>   {
>>>>>> -        Collection<SearchResult> list =
>>>>>> (Collection 
>>>>>> <SearchResult>)pageContext.getAttribute( "searchresults",
>>>>>> -
>>>>>> PageContext.REQUEST_SCOPE );
>>>>>> -
>>>>>> -        if( list != null )
>>>>>> +        if ( m_wikiActionBean != null && m_wikiActionBean  
>>>>>> instanceof
>>>>>> SearchActionBean )
>>>>>>       {
>>>>>> -            return EVAL_BODY_INCLUDE;
>>>>>> +            boolean emptyQuery =
>>>>>> ((SearchActionBean)m_wikiActionBean).getQuery() == null;
>>>>>> +            if ( !emptyQuery )
>>>>>> +            {
>>>>>> +                return EVAL_BODY_INCLUDE;
>>>>>> +            }
>>>>>>       }
>>>>>>
>>>>>>       String message = (String)pageContext.getAttribute( "err",
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>
>>


Re: svn commit: r782495 - in /incubator/jspwiki/trunk/src: WebContent/ WebContent/scripts/ WebContent/templates/default/ java/org/apache/wiki/ java/org/apache/wiki/action/ java/org/apache/wiki/tags/

Posted by Harry Metske <ha...@gmail.com>.
The large size of the HttpSession, that's definitely be a bug in
MessAdmin.First,
if I sum up all session sizes I would need a very large HeapSize, while the
JVM runs with only 256 MB.
Secondly, I took a heapdump and had a look at it with IBM's HA, that one
tells me that the (deep) size of the JSONRPCBridge is about 70k, which seems
more reasonable (but still too large for large scale use).

/Harry

2009/6/8 Harry Metske <ha...@gmail.com>

> I had a look at the HttpSession size that JSPWiki creates after adding the
> templates, and I probably must be doing something wrong.
> The session size is an awful 5.7 MB (JSONRPCBridge being the largest by
> far) :
>
> 5 attributes  Remove Attribute Attribute size Attribute name Attribute
> value
>  50 B javax.servlet.jsp.jstl.fmt.request.charset UTF-8
>  1.07 KB prefs {Editor=plain, Skin=PlainVanilla, Orientation=LEFT,
> TimeZone=Pacific/Midway, Locale=nl, SectionEditing=false,
> TimeFormat=dd-MMM-yyyy HH:mm}
>  6.92 KB templates {AJAXPreview.jsp=/templates/default/AJAXPreview.jsp,
> GroupContent.jsp=/templates/default/GroupContent.jsp,
> PageActionsBottom.jsp=/templates/default/PageActionsBottom.jsp,
> commonheader.jsp=/templates/default/commonheader.jsp,
> jspwiki.css=/templates/default/jspwiki.css,
> CommentContent.jsp=/templates/default/CommentContent.jsp,
> Footer.jsp=/templates/default/Footer.jsp,
> NewGroupContent.jsp=/templates/default/NewGroupContent.jsp,
> WorkflowContent.jsp=/templates/default/WorkflowContent.jsp,
> skins/=/templates/default/skins/,
> PageActionsTop.jsp=/templates/default/PageActionsTop.jsp,
> editors/=/templates/default/editors/,
> EditGroupContent.jsp=/templates/default/EditGroupContent.jsp,
> images/=/templates/default/images/,
> AttachmentInfoTab.jsp=/templates/default/AttachmentInfoTab.jsp,
> PageContent.jsp=/templates/default/PageContent.jsp,
> AJAXCategories.jsp=/templates/default/AJAXCategories.jsp,
> LostPasswordContent.jsp=/templates/default/LostPasswordContent.jsp,
> PreviewContent.jsp=/templates/default/PreviewContent.jsp,
> UserBox.jsp=/templates/default/UserBox.jsp,
> admin/=/templates/default/admin/,
> jspwiki_print.css=/templates/default/jspwiki_print.css,
> GroupTab.jsp=/templates/default/GroupTab.jsp,
> EditContent.jsp=/templates/default/EditContent.jsp,
> DefaultLayout.jsp=/templates/default/DefaultLayout.jsp,
> LoginContent.jsp=/templates/default/LoginContent.jsp,
> SearchBox.jsp=/templates/default/SearchBox.jsp,
> AttachmentTab.jsp=/templates/default/AttachmentTab.jsp,
> FindContent.jsp=/templates/default/FindContent.jsp,
> CreateProfileContent.jsp=/templates/default/CreateProfileContent.jsp,
> PageTab.jsp=/templates/default/PageTab.jsp,
> DisplayMessage.jsp=/templates/default/DisplayMessage.jsp,
> PreferencesTab.jsp=/templates/default/PreferencesTab.jsp,
> localheader.jsp=/templates/default/localheader.jsp,
> EditTemplate.jsp=/templates/default/EditTemplate.jsp,
> Header.jsp=/templates/default/Header.jsp,
> ProfileTab.jsp=/templates/default/ProfileTab.jsp,
> PageInfoTab.jsp=/templates/default/PageInfoTab.jsp,
> DiffTab.jsp=/templates/default/DiffTab.jsp,
> Favorites.jsp=/templates/default/Favorites.jsp,
> ViewTemplate.jsp=/templates/default/ViewTemplate.jsp,
> PreferencesContent.jsp=/templates/default/PreferencesContent.jsp,
> DiffContent.jsp=/templates/default/DiffContent.jsp}
>  5.72 MB JSONRPCBridge org.jabsorb.JSONRPCBridge@9ed91f
>  156 B breadCrumbTrail [Recent Changes]
> I'll see if I can get my hands on this if I have some more time this week.
>
> regards,
> Harry
>
>
>
> 2009/6/8 Janne Jalkanen <ja...@ecyrd.com>
>
>
>> Reminds me - the JS code used to call Ajax routines is disgustingly
>> loathsome and makes my eyes bleed and my stomach retch.  Can we upgrade to a
>> newer Mootools lib (1.2.2, I think) and switch to Request.JSON and create a
>> JSONFactory or an extension for creating our AJAX requests?
>>
>> Something like wiki.json( "Search", "ajaxSearch", { param1 : value1, ...
>> }, callback(resultobj,resulttext) ); would be nice. This would construct the
>> URL to SearchActionBean, method ajaxSearch, with the given params.
>>
>> /Janne
>>
>>
>> On 8 Jun 2009, at 21:52, Andrew Jaquith wrote:
>>
>>  It will fix this one -- but only after we've hooked it up to the
>>> client JavaScript. Should not take long.
>>>
>>> On Mon, Jun 8, 2009 at 2:44 PM, Harry Metske<ha...@gmail.com>
>>> wrote:
>>>
>>>> Andrew,
>>>>
>>>> should this patch have fixed
>>>> https://issues.apache.org/jira/browse/JSPWIKI-510 (only for 3.0 of
>>>> course) ?
>>>>
>>>> Harry
>>>>
>>>> 2009/6/8 <aj...@apache.org>
>>>>
>>>>  Author: ajaquith
>>>>> Date: Mon Jun  8 01:37:33 2009
>>>>> New Revision: 782495
>>>>>
>>>>> URL: http://svn.apache.org/viewvc?rev=782495&view=rev
>>>>> Log:
>>>>> Search.jsp migrated to Stripes. SearchActionBean now provides searching
>>>>> logic, including an ajaxSearch() method that filters results correctly
>>>>> (this
>>>>> is not hooked up to the client JavaScript yet, but it should be
>>>>> straightforward to do). Still some i18n cleanup to do.
>>>>>
>>>>> Modified:
>>>>>   incubator/jspwiki/trunk/src/WebContent/Search.jsp
>>>>>   incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-common.js
>>>>>
>>>>> incubator/jspwiki/trunk/src/WebContent/templates/default/FindContent.jsp
>>>>>   incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiContext.java
>>>>>
>>>>>
>>>>>  incubator/jspwiki/trunk/src/java/org/apache/wiki/action/SearchActionBean.java
>>>>>
>>>>>
>>>>>  incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IfNoSearchResultsTag.java
>>>>>
>>>>>
>>>>>  incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultIteratorTag.java
>>>>>
>>>>>
>>>>>  incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsSizeTag.java
>>>>>
>>>>>
>>>>>  incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsTag.java
>>>>>
>>>>> Modified: incubator/jspwiki/trunk/src/WebContent/Search.jsp
>>>>> URL:
>>>>>
>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/WebContent/Search.jsp?rev=782495&r1=782494&r2=782495&view=diff
>>>>>
>>>>>
>>>>> ==============================================================================
>>>>> --- incubator/jspwiki/trunk/src/WebContent/Search.jsp (original)
>>>>> +++ incubator/jspwiki/trunk/src/WebContent/Search.jsp Mon Jun  8
>>>>> 01:37:33
>>>>> 2009
>>>>> @@ -18,108 +18,12 @@
>>>>>    specific language governing permissions and limitations
>>>>>    under the License.
>>>>>  --%>
>>>>> -<%@ page import="org.apache.wiki.log.Logger" %>
>>>>> -<%@ page import="org.apache.wiki.log.LoggerFactory" %>
>>>>> -<%@ page import="org.apache.wiki.*" %>
>>>>> -<%@ page import="org.apache.wiki.auth.*" %>
>>>>> -<%@ page import="org.apache.wiki.auth.permissions.*" %>
>>>>> -<%@ page import="java.util.*" %>
>>>>> +<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld"
>>>>> prefix="s" %>
>>>>>  <%@ page errorPage="/Error.jsp" %>
>>>>> -<%@ page import="org.apache.wiki.search.*" %>
>>>>> -<%@ taglib uri="http://jakarta.apache.org/jspwiki.tld" prefix="wiki"
>>>>> %>
>>>>> -<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld"
>>>>> prefix="stripes" %>
>>>>> -<%@ page import="org.apache.wiki.util.TextUtil" %>
>>>>> -<%@ page import="org.apache.wiki.api.WikiPage" %>
>>>>> -<stripes:useActionBean
>>>>> beanclass="org.apache.wiki.action.SearchActionBean"
>>>>> event="find" id="wikiActionBean" />
>>>>> +<s:useActionBean beanclass="org.apache.wiki.action.SearchActionBean"
>>>>> event="search" executeResolution="true" id="wikiActionBean" />
>>>>> +<s:layout-render name="${templates['DefaultLayout.jsp']}">
>>>>> +  <s:layout-component name="content">
>>>>> +      <jsp:include page="${templates['FindContent.jsp']}" />
>>>>> +  </s:layout-component>
>>>>> +</s:layout-render>
>>>>>
>>>>> -<%!
>>>>> -    Logger log = LoggerFactory.getLogger("JSPWikiSearch");
>>>>> -%>
>>>>> -
>>>>> -<%
>>>>> -    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
>>>>> -    // Create wiki context and check for authorization
>>>>> -    WikiContext wikiContext = wiki.createContext( request,
>>>>> WikiContext.FIND );
>>>>> -    String pagereq = wikiContext.getPage().getName();
>>>>> -
>>>>> -    // Get the search results
>>>>> -    Collection list = null;
>>>>> -    String query = request.getParameter( "query");
>>>>> -    String go    = request.getParameter("go");
>>>>> -
>>>>> -    if( query != null )
>>>>> -    {
>>>>> -        log.info("Searching for string "+query);
>>>>> -
>>>>> -        try
>>>>> -        {
>>>>> -            list = wiki.findPages( query );
>>>>> -
>>>>> -            //
>>>>> -            //  Filter down to only those that we actually have a
>>>>> permission to view
>>>>> -            //
>>>>> -            AuthorizationManager mgr = wiki.getAuthorizationManager();
>>>>> -
>>>>> -            ArrayList filteredList = new ArrayList();
>>>>> -
>>>>> -            for( Iterator i = list.iterator(); i.hasNext(); )
>>>>> -            {
>>>>> -                SearchResult r = (SearchResult)i.next();
>>>>> -
>>>>> -                WikiPage p = r.getPage();
>>>>> -
>>>>> -                PagePermission pp = new PagePermission( p,
>>>>> PagePermission.VIEW_ACTION );
>>>>> -
>>>>> -                try
>>>>> -                {
>>>>> -                    if( mgr.checkPermission(
>>>>> wikiContext.getWikiSession(),
>>>>> pp ) )
>>>>> -                    {
>>>>> -                        filteredList.add( r );
>>>>> -                    }
>>>>> -                }
>>>>> -                catch( Exception e ) { log.error( "Searching for page
>>>>> "+p,
>>>>> e ); }
>>>>> -            }
>>>>> -
>>>>> -            pageContext.setAttribute( "searchresults",
>>>>> -                                      filteredList,
>>>>> -                                      PageContext.REQUEST_SCOPE );
>>>>> -        }
>>>>> -        catch( Exception e )
>>>>> -        {
>>>>> -            wikiContext.getWikiSession().addMessage( e.getMessage() );
>>>>> -        }
>>>>> -
>>>>> -        query = TextUtil.replaceEntities( query );
>>>>> -
>>>>> -        pageContext.setAttribute( "query",
>>>>> -                                  query,
>>>>> -                                  PageContext.REQUEST_SCOPE );
>>>>> -
>>>>> -        //
>>>>> -        //  Did the user click on "go"?
>>>>> -        //
>>>>> -        if( go != null )
>>>>> -        {
>>>>> -            if( list != null && list.size() > 0 )
>>>>> -            {
>>>>> -                SearchResult sr = (SearchResult)
>>>>> list.iterator().next();
>>>>> -
>>>>> -                WikiPage wikiPage = sr.getPage();
>>>>> -
>>>>> -                String url = wikiContext.getViewURL(
>>>>> wikiPage.getName() );
>>>>> -
>>>>> -                response.sendRedirect( url );
>>>>> -
>>>>> -                return;
>>>>> -            }
>>>>> -        }
>>>>> -    }
>>>>> -
>>>>> -    // Set the content type and include the response content
>>>>> -    response.setContentType("text/html;
>>>>> charset="+wiki.getContentEncoding() );
>>>>> -    String contentPage = wiki.getTemplateManager().findJSP(
>>>>> pageContext,
>>>>> -
>>>>>  wikiContext.getTemplate(),
>>>>> -
>>>>>  "ViewTemplate.jsp" );
>>>>> -%><wiki:Include page="<%=contentPage%>" /><%
>>>>> -    log.debug("SEARCH COMPLETE");
>>>>> -%>
>>>>>
>>>>> Modified:
>>>>> incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-common.js
>>>>> URL:
>>>>>
>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-common.js?rev=782495&r1=782494&r2=782495&view=diff
>>>>>
>>>>>
>>>>> ==============================================================================
>>>>> --- incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-common.js
>>>>> (original)
>>>>> +++ incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-common.js
>>>>> Mon
>>>>> Jun  8 01:37:33 2009
>>>>> @@ -931,9 +931,9 @@
>>>>>                       if (option.value == match) option.selected =
>>>>> true;
>>>>>               });
>>>>>
>>>>> -               new Ajax(Wiki.TemplateUrl+'AJAXSearch.jsp', {
>>>>> -                       postBody: $('searchform2').toQueryString(),
>>>>> -                       update: 'searchResult2',
>>>>> +               new Ajax(Wiki.BasePath+'Search.action', {
>>>>> +                       postBody:
>>>>> "ajaxSearch=&"+$('searchform2').toQueryString(),
>>>>> +                       update: 'searchResult2',
>>>>>                       method: 'post',
>>>>>                       onComplete: function() {
>>>>>                               $('spin').hide();
>>>>>
>>>>> Modified:
>>>>>
>>>>> incubator/jspwiki/trunk/src/WebContent/templates/default/FindContent.jsp
>>>>> URL:
>>>>>
>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/WebContent/templates/default/FindContent.jsp?rev=782495&r1=782494&r2=782495&view=diff
>>>>>
>>>>>
>>>>> ==============================================================================
>>>>> ---
>>>>>
>>>>> incubator/jspwiki/trunk/src/WebContent/templates/default/FindContent.jsp
>>>>> (original)
>>>>> +++
>>>>> incubator/jspwiki/trunk/src/WebContent/templates/default/FindContent.jsp
>>>>> Mon
>>>>> Jun  8 01:37:33 2009
>>>>> @@ -27,24 +27,18 @@
>>>>>  <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
>>>>>  <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
>>>>>  <%@ page import="javax.servlet.jsp.jstl.fmt.*" %>
>>>>> -<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld"
>>>>> prefix="stripes" %>
>>>>> +<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld"
>>>>> prefix="s" %>
>>>>>
>>>>>  <wiki:TabbedSection>
>>>>>  <wiki:Tab id="findcontent" titleKey="find.tab" accesskey="s">
>>>>>
>>>>> -<form action="<wiki:Link format='url' jsp='Search.jsp'/>"
>>>>> -       class="wikiform"
>>>>> -          id="searchform2"
>>>>> -         accept-charset="<wiki:ContentEncoding/>">
>>>>> -
>>>>> +<s:form beanclass="org.apache.wiki.action.SearchActionBean"
>>>>> class="wikiform"
>>>>> +    id="searchform2" acceptcharset="UTF-8">
>>>>> +
>>>>>  <h4><fmt:message key="find.input" /></h4>
>>>>>  <p>
>>>>> -    <input type="text"
>>>>> -           name="query" id="query2"
>>>>> -          value="<c:out value='${query}'/>"
>>>>> -           size="32" />
>>>>> -
>>>>> -    <input type="checkbox" name="details" id="details" <c:if
>>>>> test='${param.details == "on"}'>checked='checked'</c:if> />
>>>>> +    <s:text name="query" id="query2" size="32" />
>>>>> +    <s:checkbox name="details" id="details" />
>>>>>    <fmt:message key="find.details" />
>>>>>
>>>>>    <select name="scope" id="scope">
>>>>> @@ -55,16 +49,83 @@
>>>>>      <option value="attachment:" <c:if test='${param.scope eq
>>>>> "attachment:"}'>selected="selected"</c:if> ><fmt:message
>>>>> key='find.scope.attach' /></option>
>>>>>    </select>
>>>>>
>>>>> -       <input type="submit" name="ok" id="ok" value="<fmt:message
>>>>> key="find.submit.find" />" />
>>>>> -       <input type="submit" name="go" id="go" value="<fmt:message
>>>>> key="find.submit.go" />" />
>>>>> -    <input type="hidden" name="start" id="start" value="0" />
>>>>> -    <input type="hidden" name="maxitems" id="maxitems" value="20" />
>>>>> +    <s:submit name="search" id="ok" value="<fmt:message
>>>>> key='find.submit.find' />" />
>>>>> +    <s:submit name="go" id="go" value="<fmt:message
>>>>> key='find.submit.go'
>>>>> />" />
>>>>> +    <s:hidden name="start" id="start" value="0" />
>>>>> +    <s:hidden name="maxItems" id="maxitems" value="20" />
>>>>>
>>>>>    <span id="spin" class="spin"
>>>>> style="position:absolute;display:none;"></span>
>>>>>  </p>
>>>>> -</form>
>>>>> +</s:form>
>>>>> +
>>>>> +<div id="searchResult2">
>>>>> +  <wiki:SearchResults>
>>>>> +
>>>>> +    <h4><fmt:message key="find.heading.results"><fmt:param><c:out
>>>>> value="${wikiActionBean.query}" /></fmt:param></fmt:message></h4>
>>>>> +    <p>
>>>>> +      <fmt:message key="find.externalsearch" />
>>>>> +      <a class="external" href="http://www.google.com/search?q=<c:out
>>>>> value='${wikiActionBean.query}' />" title="Google Search '<c:out
>>>>> value='${wikiActionBean.query}' />'" target="_blank">Google</a><img
>>>>> class="outlink" src="images/out.png" alt="" />
>>>>> +      |
>>>>> +      <a class="external" href="
>>>>> http://en.wikipedia.org/wiki/Special:Search?search=<c:out
>>>>> value='${wikiActionBean.query}' />" title="Wikipedia Search '<c:out
>>>>> value='${wikiActionBean.query}' />'" target="_blank">Wikipedia</a><img
>>>>> class="outlink" src="images/out.png" alt="" />
>>>>> +    </p>
>>>>> +
>>>>> +    <wiki:SetPagination start="${wikiActionBean.start}"
>>>>> total="${wikiActionBean.resultsCount}" pagesize="20" maxlinks="9"
>>>>> fmtkey="info.pagination" onclick="$('start').value=%s;
>>>>> SearchBox.runfullsearch();" />
>>>>> +
>>>>> +    <div class="graphBars">
>>>>> +      <div class="zebra-table">
>>>>> +        <table class="wikitable">
>>>>> +
>>>>> +          <tr>
>>>>> +             <th align="left"><fmt:message key="find.results.page"
>>>>> /></th>
>>>>> +             <th align="left"><fmt:message key="find.results.score"
>>>>> /></th>
>>>>> +          </tr>
>>>>> +
>>>>> +          <wiki:SearchResultIterator id="searchref"
>>>>> start="${wikiActionBean.start}" maxItems="${wikiActionBean.maxItems}">
>>>>> +          <tr>
>>>>> +            <td><wiki:LinkTo><wiki:PageName/></wiki:LinkTo></td>
>>>>> +            <td><span class="gBar"><%= searchref.getScore()
>>>>> %></span></td>
>>>>> +          </tr>
>>>>> +
>>>>> +          <c:if test="${wikiActionBean.details == 'true'}">
>>>>> +  <%
>>>>> +            String[] contexts = searchref.getContexts();
>>>>> +            if( (contexts != null) && (contexts.length > 0) )
>>>>> +            {
>>>>> +  %>
>>>>> +          <tr class="odd">
>>>>> +            <td colspan="2">
>>>>> +              <div class="fragment">
>>>>> +  <%
>>>>> +              for (int i = 0; i < contexts.length; i++)
>>>>> +              {
>>>>> +  %>
>>>>> +                <%= (i > 0 ) ? "<span class='fragment_ellipsis'> ...
>>>>> </span>" : ""  %>
>>>>> +                <%= contexts[i]  %>
>>>>> +  <%
>>>>> +              }
>>>>> +  %>
>>>>> +               </div>
>>>>> +             </td>
>>>>> +           </tr>
>>>>> +  <%
>>>>> +            }
>>>>> +  %>
>>>>> +          </c:if><%-- details --%>
>>>>> +        </wiki:SearchResultIterator>
>>>>> +
>>>>> +        <wiki:IfNoSearchResults>
>>>>> +          <tr>
>>>>> +            <td class="nosearchresult" colspan="2"><fmt:message
>>>>> key="find.noresults" /></td>
>>>>> +          </tr>
>>>>> +        </wiki:IfNoSearchResults>
>>>>> +
>>>>> +        </table>
>>>>> +      </div>
>>>>> +    </div>
>>>>> +    ${pagination}
>>>>>
>>>>> -<div id="searchResult2"><wiki:Include page="AJAXSearch.jsp" /></div>
>>>>> +  </wiki:SearchResults>
>>>>> +</div>
>>>>>
>>>>>  </wiki:Tab>
>>>>>
>>>>>
>>>>> Modified:
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiContext.java
>>>>> URL:
>>>>>
>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiContext.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>>
>>>>>
>>>>> ==============================================================================
>>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiContext.java
>>>>> (original)
>>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiContext.java
>>>>> Mon
>>>>> Jun  8 01:37:33 2009
>>>>> @@ -103,7 +103,7 @@
>>>>>    public static final String    COMMENT  = HandlerInfo.getHandlerInfo(
>>>>> EditActionBean.class, "comment" ).getRequestContext();
>>>>>
>>>>>    /** User is searching for content. */
>>>>> -    public static final String    FIND     =
>>>>> HandlerInfo.getHandlerInfo(
>>>>> SearchActionBean.class, "find" ).getRequestContext();
>>>>> +    public static final String    FIND     =
>>>>> HandlerInfo.getHandlerInfo(
>>>>> SearchActionBean.class, "search" ).getRequestContext();
>>>>>
>>>>>    /** User wishes to create a new group */
>>>>>    public static final String    CREATE_GROUP =
>>>>> HandlerInfo.getHandlerInfo( GroupActionBean.class, "create"
>>>>> ).getRequestContext();
>>>>>
>>>>> Modified:
>>>>>
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/action/SearchActionBean.java
>>>>> URL:
>>>>>
>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/action/SearchActionBean.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>>
>>>>>
>>>>> ==============================================================================
>>>>> ---
>>>>>
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/action/SearchActionBean.java
>>>>> (original)
>>>>> +++
>>>>>
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/action/SearchActionBean.java
>>>>> Mon Jun  8 01:37:33 2009
>>>>> @@ -21,18 +21,191 @@
>>>>>
>>>>>  package org.apache.wiki.action;
>>>>>
>>>>> -import org.apache.wiki.ui.stripes.WikiRequestContext;
>>>>> +import java.util.ArrayList;
>>>>> +import java.util.Collection;
>>>>> +import java.util.Collections;
>>>>> +import java.util.List;
>>>>>
>>>>>  import net.sourceforge.stripes.action.*;
>>>>> +import net.sourceforge.stripes.ajax.JavaScriptResolution;
>>>>> +
>>>>> +import org.apache.wiki.WikiEngine;
>>>>> +import org.apache.wiki.api.WikiPage;
>>>>> +import org.apache.wiki.auth.AuthorizationManager;
>>>>> +import org.apache.wiki.auth.permissions.PagePermission;
>>>>> +import org.apache.wiki.log.Logger;
>>>>> +import org.apache.wiki.log.LoggerFactory;
>>>>> +import org.apache.wiki.search.SearchResult;
>>>>> +import org.apache.wiki.ui.stripes.WikiRequestContext;
>>>>>
>>>>> +/**
>>>>> + * Searches the WikiPage collection for a given wiki.
>>>>> + */
>>>>>  @UrlBinding( "/Search.jsp" )
>>>>>  public class SearchActionBean extends AbstractActionBean
>>>>>  {
>>>>> +    private Logger log = LoggerFactory.getLogger("JSPWikiSearch");
>>>>> +
>>>>> +    public static final Collection<SearchResult> NO_RESULTS =
>>>>> Collections.emptyList();
>>>>> +
>>>>> +    private Collection<SearchResult> m_results = NO_RESULTS;
>>>>> +
>>>>> +    private String m_query = null;
>>>>> +
>>>>> +    private int m_maxItems = 20;
>>>>> +
>>>>> +    private int m_start = 0;
>>>>> +
>>>>> +    private boolean m_details = false;
>>>>> +
>>>>> +    public boolean getDetails()
>>>>> +    {
>>>>> +        return m_details;
>>>>> +    }
>>>>> +
>>>>> +    /**
>>>>> +     * Sets the search results so that details for each result are
>>>>> displayed.
>>>>> +     * @param details whether details should be displayed
>>>>> +     */
>>>>> +    public void setDetails( boolean details )
>>>>> +    {
>>>>> +        m_details = details;
>>>>> +    }
>>>>> +
>>>>> +    public int getMaxItems()
>>>>> +    {
>>>>> +        return m_maxItems;
>>>>> +    }
>>>>> +
>>>>> +    public void setMaxItems( int maxItems )
>>>>> +    {
>>>>> +        m_maxItems = maxItems;
>>>>> +    }
>>>>> +
>>>>> +    public int getStart()
>>>>> +    {
>>>>> +        return m_start;
>>>>> +    }
>>>>> +
>>>>> +    public void setStart( int start )
>>>>> +    {
>>>>> +        m_start = start;
>>>>> +    }
>>>>> +
>>>>> +    /**
>>>>> +     * Returns the query string for the search.
>>>>> +     *
>>>>> +     * @return the query string
>>>>> +     */
>>>>> +    public String getQuery()
>>>>> +    {
>>>>> +        return m_query;
>>>>> +    }
>>>>> +
>>>>> +    /**
>>>>> +     * Returns the results of the search.
>>>>> +     *
>>>>> +     * @return the results
>>>>> +     */
>>>>> +    public Collection<SearchResult> getResults()
>>>>> +    {
>>>>> +        return m_results;
>>>>> +    }
>>>>> +
>>>>> +    /**
>>>>> +     * Returns the number of items returned by the current search.
>>>>> +     * @return the number of items
>>>>> +     */
>>>>> +    public int getResultsCount()
>>>>> +    {
>>>>> +        return m_results.size();
>>>>> +    }
>>>>> +
>>>>> +    /**
>>>>> +     * Performs a search and returns the results as a list. For a
>>>>> given
>>>>> WikiPage to
>>>>> +     * be included in the results, the user must have permission to
>>>>> view
>>>>> it.
>>>>> +     * If the underlying providers encounter an abnormal IOException
>>>>> or
>>>>> other error,
>>>>> +     * it will be added to the ActionBeanContext's validation messages
>>>>> collection.
>>>>> +     * @param query the query
>>>>> +     * @return the results
>>>>> +     */
>>>>> +    private List<SearchResult> doSearch( String query )
>>>>> +    {
>>>>> +        log.info("Searching with query '"+ query + "'.");
>>>>> +        WikiEngine engine = getContext().getEngine();
>>>>> +        AuthorizationManager mgr = engine.getAuthorizationManager();
>>>>> +
>>>>> +        //
>>>>> +        //  Filter down to only those that we actually have a
>>>>> permission
>>>>> to view
>>>>> +        //
>>>>> +        List<SearchResult> filteredResults = new
>>>>> ArrayList<SearchResult>();
>>>>> +        try
>>>>> +        {
>>>>> +            List<SearchResult> results = engine.findPages( query );
>>>>> +            for( SearchResult result : results )
>>>>> +            {
>>>>> +                WikiPage page = result.getPage();
>>>>> +                PagePermission permission = new PagePermission( page,
>>>>> PagePermission.VIEW_ACTION );
>>>>> +                try
>>>>> +                {
>>>>> +                    if( mgr.checkPermission(
>>>>> getContext().getWikiSession(), permission ) )
>>>>> +                    {
>>>>> +                        filteredResults.add( result );
>>>>> +                    }
>>>>> +                }
>>>>> +                catch( Exception e ) { log.error( "Searching for page
>>>>> " +
>>>>> page, e ); }
>>>>> +            }
>>>>> +        }
>>>>> +        catch( Exception e )
>>>>> +        {
>>>>> +            log.debug( "Could not search using query '" + query +
>>>>> "'.", e
>>>>> );
>>>>> +            Message message = new SimpleMessage( e.getMessage() );
>>>>> +            getContext().getMessages().add( message );
>>>>> +            e.printStackTrace();
>>>>> +        }
>>>>> +        return filteredResults;
>>>>> +    }
>>>>> +
>>>>> +    /**
>>>>> +     * Sets the query string for the search.
>>>>> +     *
>>>>> +     * @param query the query string
>>>>> +     */
>>>>> +    public void setQuery( String query )
>>>>> +    {
>>>>> +        m_query = query;
>>>>> +    }
>>>>> +
>>>>> +    /**
>>>>> +     * Searches the wiki using the query string set for this
>>>>> +     * ActionBean. Search results are made available to callers via
>>>>> the
>>>>> +     * {@link #getResults()} method (and EL expression
>>>>> +     * <code>$wikiActionBean.results</code>).
>>>>> +     *
>>>>> +     * @return always returns a {@link ForwardResolution} to
>>>>> +     *         <code>/Search.jsp</code>.
>>>>> +     */
>>>>>    @DefaultHandler
>>>>> -    @HandlesEvent( "find" )
>>>>> +    @HandlesEvent( "search" )
>>>>>    @WikiRequestContext( "find" )
>>>>> -    public Resolution view()
>>>>> +    public Resolution search()
>>>>>    {
>>>>> +        m_results = m_query == null ? NO_RESULTS : doSearch( m_query
>>>>> );
>>>>>        return new ForwardResolution( "/Search.jsp" );
>>>>>    }
>>>>> +
>>>>> +    /**
>>>>> +     * Using AJAX, searches a specified wiki space using the query
>>>>> string
>>>>> set for this
>>>>> +     * ActionBean. Results are streamed back to the client as an array
>>>>> of
>>>>> JSON-encoded
>>>>> +     * SearchResult objects.
>>>>> +     *
>>>>> +     * @return always returns a {@link JavaScriptResolution}
>>>>> containing
>>>>> the
>>>>> +     * results; this may be a zero-length array
>>>>> +     */
>>>>> +    @HandlesEvent( "ajaxSearch" )
>>>>> +    public Resolution ajaxSearch()
>>>>> +    {
>>>>> +        m_results = m_query == null ? NO_RESULTS : doSearch( m_query
>>>>> );
>>>>> +        return new JavaScriptResolution( m_results );
>>>>> +    }
>>>>>  }
>>>>>
>>>>> Modified:
>>>>>
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IfNoSearchResultsTag.java
>>>>> URL:
>>>>>
>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IfNoSearchResultsTag.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>>
>>>>>
>>>>> ==============================================================================
>>>>> ---
>>>>>
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IfNoSearchResultsTag.java
>>>>> (original)
>>>>> +++
>>>>>
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IfNoSearchResultsTag.java
>>>>> Mon Jun  8 01:37:33 2009
>>>>> @@ -22,8 +22,8 @@
>>>>>
>>>>>  import java.io.IOException;
>>>>>  import java.util.Collection;
>>>>> -import javax.servlet.jsp.PageContext;
>>>>>
>>>>> +import org.apache.wiki.action.SearchActionBean;
>>>>>  import org.apache.wiki.search.SearchResult;
>>>>>
>>>>>  /**
>>>>> @@ -36,17 +36,18 @@
>>>>>  {
>>>>>    private static final long serialVersionUID = 0L;
>>>>>
>>>>> -    @SuppressWarnings("unchecked")
>>>>>    public final int doWikiStartTag()
>>>>>        throws IOException
>>>>>    {
>>>>> -        Collection<SearchResult> list =
>>>>> (Collection<SearchResult>)pageContext.getAttribute( "searchresults",
>>>>> -
>>>>>  PageContext.REQUEST_SCOPE );
>>>>> -        if( list == null || list.size() == 0 )
>>>>> -        {
>>>>> -            return EVAL_BODY_INCLUDE;
>>>>> +        if ( m_wikiActionBean != null && m_wikiActionBean instanceof
>>>>> SearchActionBean )
>>>>> +        {
>>>>> +            boolean emptyQuery =
>>>>> ((SearchActionBean)m_wikiActionBean).getQuery() == null;
>>>>> +            Collection<SearchResult> results =
>>>>> ((SearchActionBean)m_wikiActionBean).getResults();
>>>>> +            if ( emptyQuery || results.size() > 0 )
>>>>> +            {
>>>>> +                return SKIP_BODY;
>>>>> +            }
>>>>>        }
>>>>> -
>>>>> -        return SKIP_BODY;
>>>>> +        return EVAL_BODY_INCLUDE;
>>>>>    }
>>>>>  }
>>>>>
>>>>> Modified:
>>>>>
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultIteratorTag.java
>>>>> URL:
>>>>>
>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultIteratorTag.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>>
>>>>>
>>>>> ==============================================================================
>>>>> ---
>>>>>
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultIteratorTag.java
>>>>> (original)
>>>>> +++
>>>>>
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultIteratorTag.java
>>>>> Mon Jun  8 01:37:33 2009
>>>>> @@ -20,12 +20,12 @@
>>>>>  */
>>>>>  package org.apache.wiki.tags;
>>>>>
>>>>> -import java.util.ArrayList;
>>>>>  import java.util.Collection;
>>>>>
>>>>> -import javax.servlet.jsp.PageContext;
>>>>> -
>>>>> +import org.apache.wiki.action.SearchActionBean;
>>>>> +import org.apache.wiki.action.WikiActionBean;
>>>>>  import org.apache.wiki.search.SearchResult;
>>>>> +import org.apache.wiki.ui.stripes.WikiInterceptor;
>>>>>
>>>>>  /**
>>>>>  * Iterator tag for the current search results, as identified by a
>>>>> @@ -36,19 +36,17 @@
>>>>>    private static final long serialVersionUID = 1L;
>>>>>
>>>>>    /**
>>>>> -     * \ Returns the list of SearchResults to iterate over.
>>>>> +     * Returns the list of SearchResults to iterate over.
>>>>>     */
>>>>>    @Override
>>>>> -    @SuppressWarnings( "unchecked" )
>>>>>    protected Collection<SearchResult> initItems()
>>>>>    {
>>>>> -        Collection<SearchResult> results = (Collection<SearchResult>)
>>>>> pageContext.getAttribute( "searchresults",
>>>>> -
>>>>>                     PageContext.REQUEST_SCOPE );
>>>>> -        if( results == null )
>>>>> +        WikiActionBean actionBean = WikiInterceptor.findActionBean(
>>>>> pageContext );
>>>>> +        if ( actionBean != null && actionBean instanceof
>>>>> SearchActionBean
>>>>> )
>>>>>        {
>>>>> -            return new ArrayList<SearchResult>();
>>>>> +            return ((SearchActionBean)actionBean).getResults();
>>>>>        }
>>>>> -        return results;
>>>>> +        return SearchActionBean.NO_RESULTS;
>>>>>    }
>>>>>
>>>>>    /**
>>>>>
>>>>> Modified:
>>>>>
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsSizeTag.java
>>>>> URL:
>>>>>
>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsSizeTag.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>>
>>>>>
>>>>> ==============================================================================
>>>>> ---
>>>>>
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsSizeTag.java
>>>>> (original)
>>>>> +++
>>>>>
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsSizeTag.java
>>>>> Mon Jun  8 01:37:33 2009
>>>>> @@ -22,8 +22,8 @@
>>>>>
>>>>>  import java.io.IOException;
>>>>>  import java.util.Collection;
>>>>> -import javax.servlet.jsp.PageContext;
>>>>>
>>>>> +import org.apache.wiki.action.SearchActionBean;
>>>>>  import org.apache.wiki.search.SearchResult;
>>>>>
>>>>>  /**
>>>>> @@ -37,17 +37,14 @@
>>>>>  {
>>>>>    private static final long serialVersionUID = 0L;
>>>>>
>>>>> -    @SuppressWarnings("unchecked")
>>>>>    public final int doWikiStartTag()
>>>>>        throws IOException
>>>>>    {
>>>>> -        Collection<SearchResult> list =
>>>>> (Collection<SearchResult>)pageContext.getAttribute( "searchresults",
>>>>> -
>>>>>  PageContext.REQUEST_SCOPE );
>>>>> -        if( list != null )
>>>>> +        if ( m_wikiActionBean != null && m_wikiActionBean instanceof
>>>>> SearchActionBean )
>>>>>        {
>>>>> -            pageContext.getOut().print( list.size() );
>>>>> +            Collection<SearchResult> results =
>>>>> ((SearchActionBean)m_wikiActionBean).getResults();
>>>>> +            pageContext.getOut().print( results.size() );
>>>>>        }
>>>>> -
>>>>>        return SKIP_BODY;
>>>>>    }
>>>>>  }
>>>>>
>>>>> Modified:
>>>>>
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsTag.java
>>>>> URL:
>>>>>
>>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsTag.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>>
>>>>>
>>>>> ==============================================================================
>>>>> ---
>>>>>
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsTag.java
>>>>> (original)
>>>>> +++
>>>>>
>>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsTag.java
>>>>> Mon Jun  8 01:37:33 2009
>>>>> @@ -21,10 +21,10 @@
>>>>>  package org.apache.wiki.tags;
>>>>>
>>>>>  import java.io.IOException;
>>>>> -import java.util.Collection;
>>>>> +
>>>>>  import javax.servlet.jsp.PageContext;
>>>>>
>>>>> -import org.apache.wiki.search.SearchResult;
>>>>> +import org.apache.wiki.action.SearchActionBean;
>>>>>
>>>>>  /**
>>>>>  *  Includes the body content, if there are any search results.
>>>>> @@ -36,16 +36,16 @@
>>>>>  {
>>>>>    private static final long serialVersionUID = 0L;
>>>>>
>>>>> -    @SuppressWarnings("unchecked")
>>>>>    public final int doWikiStartTag()
>>>>>        throws IOException
>>>>>    {
>>>>> -        Collection<SearchResult> list =
>>>>> (Collection<SearchResult>)pageContext.getAttribute( "searchresults",
>>>>> -
>>>>>  PageContext.REQUEST_SCOPE );
>>>>> -
>>>>> -        if( list != null )
>>>>> +        if ( m_wikiActionBean != null && m_wikiActionBean instanceof
>>>>> SearchActionBean )
>>>>>        {
>>>>> -            return EVAL_BODY_INCLUDE;
>>>>> +            boolean emptyQuery =
>>>>> ((SearchActionBean)m_wikiActionBean).getQuery() == null;
>>>>> +            if ( !emptyQuery )
>>>>> +            {
>>>>> +                return EVAL_BODY_INCLUDE;
>>>>> +            }
>>>>>        }
>>>>>
>>>>>        String message = (String)pageContext.getAttribute( "err",
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>
>

Re: svn commit: r782495 - in /incubator/jspwiki/trunk/src: WebContent/ WebContent/scripts/ WebContent/templates/default/ java/org/apache/wiki/ java/org/apache/wiki/action/ java/org/apache/wiki/tags/

Posted by Harry Metske <ha...@gmail.com>.
I had a look at the HttpSession size that JSPWiki creates after adding the
templates, and I probably must be doing something wrong.
The session size is an awful 5.7 MB (JSONRPCBridge being the largest by far)
:

5 attributes  Remove Attribute Attribute size Attribute name Attribute value
50 B javax.servlet.jsp.jstl.fmt.request.charset UTF-8
1.07 KB prefs {Editor=plain, Skin=PlainVanilla, Orientation=LEFT,
TimeZone=Pacific/Midway, Locale=nl, SectionEditing=false,
TimeFormat=dd-MMM-yyyy HH:mm}
6.92 KB templates {AJAXPreview.jsp=/templates/default/AJAXPreview.jsp,
GroupContent.jsp=/templates/default/GroupContent.jsp,
PageActionsBottom.jsp=/templates/default/PageActionsBottom.jsp,
commonheader.jsp=/templates/default/commonheader.jsp,
jspwiki.css=/templates/default/jspwiki.css,
CommentContent.jsp=/templates/default/CommentContent.jsp,
Footer.jsp=/templates/default/Footer.jsp,
NewGroupContent.jsp=/templates/default/NewGroupContent.jsp,
WorkflowContent.jsp=/templates/default/WorkflowContent.jsp,
skins/=/templates/default/skins/,
PageActionsTop.jsp=/templates/default/PageActionsTop.jsp,
editors/=/templates/default/editors/,
EditGroupContent.jsp=/templates/default/EditGroupContent.jsp,
images/=/templates/default/images/,
AttachmentInfoTab.jsp=/templates/default/AttachmentInfoTab.jsp,
PageContent.jsp=/templates/default/PageContent.jsp,
AJAXCategories.jsp=/templates/default/AJAXCategories.jsp,
LostPasswordContent.jsp=/templates/default/LostPasswordContent.jsp,
PreviewContent.jsp=/templates/default/PreviewContent.jsp,
UserBox.jsp=/templates/default/UserBox.jsp,
admin/=/templates/default/admin/,
jspwiki_print.css=/templates/default/jspwiki_print.css,
GroupTab.jsp=/templates/default/GroupTab.jsp,
EditContent.jsp=/templates/default/EditContent.jsp,
DefaultLayout.jsp=/templates/default/DefaultLayout.jsp,
LoginContent.jsp=/templates/default/LoginContent.jsp,
SearchBox.jsp=/templates/default/SearchBox.jsp,
AttachmentTab.jsp=/templates/default/AttachmentTab.jsp,
FindContent.jsp=/templates/default/FindContent.jsp,
CreateProfileContent.jsp=/templates/default/CreateProfileContent.jsp,
PageTab.jsp=/templates/default/PageTab.jsp,
DisplayMessage.jsp=/templates/default/DisplayMessage.jsp,
PreferencesTab.jsp=/templates/default/PreferencesTab.jsp,
localheader.jsp=/templates/default/localheader.jsp,
EditTemplate.jsp=/templates/default/EditTemplate.jsp,
Header.jsp=/templates/default/Header.jsp,
ProfileTab.jsp=/templates/default/ProfileTab.jsp,
PageInfoTab.jsp=/templates/default/PageInfoTab.jsp,
DiffTab.jsp=/templates/default/DiffTab.jsp,
Favorites.jsp=/templates/default/Favorites.jsp,
ViewTemplate.jsp=/templates/default/ViewTemplate.jsp,
PreferencesContent.jsp=/templates/default/PreferencesContent.jsp,
DiffContent.jsp=/templates/default/DiffContent.jsp}
5.72 MB JSONRPCBridge org.jabsorb.JSONRPCBridge@9ed91f
156 B breadCrumbTrail [Recent Changes]
I'll see if I can get my hands on this if I have some more time this week.

regards,
Harry



2009/6/8 Janne Jalkanen <ja...@ecyrd.com>

>
> Reminds me - the JS code used to call Ajax routines is disgustingly
> loathsome and makes my eyes bleed and my stomach retch.  Can we upgrade to a
> newer Mootools lib (1.2.2, I think) and switch to Request.JSON and create a
> JSONFactory or an extension for creating our AJAX requests?
>
> Something like wiki.json( "Search", "ajaxSearch", { param1 : value1, ... },
> callback(resultobj,resulttext) ); would be nice. This would construct the
> URL to SearchActionBean, method ajaxSearch, with the given params.
>
> /Janne
>
>
> On 8 Jun 2009, at 21:52, Andrew Jaquith wrote:
>
>  It will fix this one -- but only after we've hooked it up to the
>> client JavaScript. Should not take long.
>>
>> On Mon, Jun 8, 2009 at 2:44 PM, Harry Metske<ha...@gmail.com>
>> wrote:
>>
>>> Andrew,
>>>
>>> should this patch have fixed
>>> https://issues.apache.org/jira/browse/JSPWIKI-510 (only for 3.0 of
>>> course) ?
>>>
>>> Harry
>>>
>>> 2009/6/8 <aj...@apache.org>
>>>
>>>  Author: ajaquith
>>>> Date: Mon Jun  8 01:37:33 2009
>>>> New Revision: 782495
>>>>
>>>> URL: http://svn.apache.org/viewvc?rev=782495&view=rev
>>>> Log:
>>>> Search.jsp migrated to Stripes. SearchActionBean now provides searching
>>>> logic, including an ajaxSearch() method that filters results correctly
>>>> (this
>>>> is not hooked up to the client JavaScript yet, but it should be
>>>> straightforward to do). Still some i18n cleanup to do.
>>>>
>>>> Modified:
>>>>   incubator/jspwiki/trunk/src/WebContent/Search.jsp
>>>>   incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-common.js
>>>>
>>>> incubator/jspwiki/trunk/src/WebContent/templates/default/FindContent.jsp
>>>>   incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiContext.java
>>>>
>>>>
>>>>  incubator/jspwiki/trunk/src/java/org/apache/wiki/action/SearchActionBean.java
>>>>
>>>>
>>>>  incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IfNoSearchResultsTag.java
>>>>
>>>>
>>>>  incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultIteratorTag.java
>>>>
>>>>
>>>>  incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsSizeTag.java
>>>>
>>>>
>>>>  incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsTag.java
>>>>
>>>> Modified: incubator/jspwiki/trunk/src/WebContent/Search.jsp
>>>> URL:
>>>>
>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/WebContent/Search.jsp?rev=782495&r1=782494&r2=782495&view=diff
>>>>
>>>>
>>>> ==============================================================================
>>>> --- incubator/jspwiki/trunk/src/WebContent/Search.jsp (original)
>>>> +++ incubator/jspwiki/trunk/src/WebContent/Search.jsp Mon Jun  8
>>>> 01:37:33
>>>> 2009
>>>> @@ -18,108 +18,12 @@
>>>>    specific language governing permissions and limitations
>>>>    under the License.
>>>>  --%>
>>>> -<%@ page import="org.apache.wiki.log.Logger" %>
>>>> -<%@ page import="org.apache.wiki.log.LoggerFactory" %>
>>>> -<%@ page import="org.apache.wiki.*" %>
>>>> -<%@ page import="org.apache.wiki.auth.*" %>
>>>> -<%@ page import="org.apache.wiki.auth.permissions.*" %>
>>>> -<%@ page import="java.util.*" %>
>>>> +<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld" prefix="s"
>>>> %>
>>>>  <%@ page errorPage="/Error.jsp" %>
>>>> -<%@ page import="org.apache.wiki.search.*" %>
>>>> -<%@ taglib uri="http://jakarta.apache.org/jspwiki.tld" prefix="wiki"
>>>> %>
>>>> -<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld"
>>>> prefix="stripes" %>
>>>> -<%@ page import="org.apache.wiki.util.TextUtil" %>
>>>> -<%@ page import="org.apache.wiki.api.WikiPage" %>
>>>> -<stripes:useActionBean
>>>> beanclass="org.apache.wiki.action.SearchActionBean"
>>>> event="find" id="wikiActionBean" />
>>>> +<s:useActionBean beanclass="org.apache.wiki.action.SearchActionBean"
>>>> event="search" executeResolution="true" id="wikiActionBean" />
>>>> +<s:layout-render name="${templates['DefaultLayout.jsp']}">
>>>> +  <s:layout-component name="content">
>>>> +      <jsp:include page="${templates['FindContent.jsp']}" />
>>>> +  </s:layout-component>
>>>> +</s:layout-render>
>>>>
>>>> -<%!
>>>> -    Logger log = LoggerFactory.getLogger("JSPWikiSearch");
>>>> -%>
>>>> -
>>>> -<%
>>>> -    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
>>>> -    // Create wiki context and check for authorization
>>>> -    WikiContext wikiContext = wiki.createContext( request,
>>>> WikiContext.FIND );
>>>> -    String pagereq = wikiContext.getPage().getName();
>>>> -
>>>> -    // Get the search results
>>>> -    Collection list = null;
>>>> -    String query = request.getParameter( "query");
>>>> -    String go    = request.getParameter("go");
>>>> -
>>>> -    if( query != null )
>>>> -    {
>>>> -        log.info("Searching for string "+query);
>>>> -
>>>> -        try
>>>> -        {
>>>> -            list = wiki.findPages( query );
>>>> -
>>>> -            //
>>>> -            //  Filter down to only those that we actually have a
>>>> permission to view
>>>> -            //
>>>> -            AuthorizationManager mgr = wiki.getAuthorizationManager();
>>>> -
>>>> -            ArrayList filteredList = new ArrayList();
>>>> -
>>>> -            for( Iterator i = list.iterator(); i.hasNext(); )
>>>> -            {
>>>> -                SearchResult r = (SearchResult)i.next();
>>>> -
>>>> -                WikiPage p = r.getPage();
>>>> -
>>>> -                PagePermission pp = new PagePermission( p,
>>>> PagePermission.VIEW_ACTION );
>>>> -
>>>> -                try
>>>> -                {
>>>> -                    if( mgr.checkPermission(
>>>> wikiContext.getWikiSession(),
>>>> pp ) )
>>>> -                    {
>>>> -                        filteredList.add( r );
>>>> -                    }
>>>> -                }
>>>> -                catch( Exception e ) { log.error( "Searching for page
>>>> "+p,
>>>> e ); }
>>>> -            }
>>>> -
>>>> -            pageContext.setAttribute( "searchresults",
>>>> -                                      filteredList,
>>>> -                                      PageContext.REQUEST_SCOPE );
>>>> -        }
>>>> -        catch( Exception e )
>>>> -        {
>>>> -            wikiContext.getWikiSession().addMessage( e.getMessage() );
>>>> -        }
>>>> -
>>>> -        query = TextUtil.replaceEntities( query );
>>>> -
>>>> -        pageContext.setAttribute( "query",
>>>> -                                  query,
>>>> -                                  PageContext.REQUEST_SCOPE );
>>>> -
>>>> -        //
>>>> -        //  Did the user click on "go"?
>>>> -        //
>>>> -        if( go != null )
>>>> -        {
>>>> -            if( list != null && list.size() > 0 )
>>>> -            {
>>>> -                SearchResult sr = (SearchResult)
>>>> list.iterator().next();
>>>> -
>>>> -                WikiPage wikiPage = sr.getPage();
>>>> -
>>>> -                String url = wikiContext.getViewURL( wikiPage.getName()
>>>> );
>>>> -
>>>> -                response.sendRedirect( url );
>>>> -
>>>> -                return;
>>>> -            }
>>>> -        }
>>>> -    }
>>>> -
>>>> -    // Set the content type and include the response content
>>>> -    response.setContentType("text/html;
>>>> charset="+wiki.getContentEncoding() );
>>>> -    String contentPage = wiki.getTemplateManager().findJSP(
>>>> pageContext,
>>>> -
>>>>  wikiContext.getTemplate(),
>>>> -
>>>>  "ViewTemplate.jsp" );
>>>> -%><wiki:Include page="<%=contentPage%>" /><%
>>>> -    log.debug("SEARCH COMPLETE");
>>>> -%>
>>>>
>>>> Modified:
>>>> incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-common.js
>>>> URL:
>>>>
>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-common.js?rev=782495&r1=782494&r2=782495&view=diff
>>>>
>>>>
>>>> ==============================================================================
>>>> --- incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-common.js
>>>> (original)
>>>> +++ incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-common.js Mon
>>>> Jun  8 01:37:33 2009
>>>> @@ -931,9 +931,9 @@
>>>>                       if (option.value == match) option.selected = true;
>>>>               });
>>>>
>>>> -               new Ajax(Wiki.TemplateUrl+'AJAXSearch.jsp', {
>>>> -                       postBody: $('searchform2').toQueryString(),
>>>> -                       update: 'searchResult2',
>>>> +               new Ajax(Wiki.BasePath+'Search.action', {
>>>> +                       postBody:
>>>> "ajaxSearch=&"+$('searchform2').toQueryString(),
>>>> +                       update: 'searchResult2',
>>>>                       method: 'post',
>>>>                       onComplete: function() {
>>>>                               $('spin').hide();
>>>>
>>>> Modified:
>>>> incubator/jspwiki/trunk/src/WebContent/templates/default/FindContent.jsp
>>>> URL:
>>>>
>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/WebContent/templates/default/FindContent.jsp?rev=782495&r1=782494&r2=782495&view=diff
>>>>
>>>>
>>>> ==============================================================================
>>>> ---
>>>> incubator/jspwiki/trunk/src/WebContent/templates/default/FindContent.jsp
>>>> (original)
>>>> +++
>>>> incubator/jspwiki/trunk/src/WebContent/templates/default/FindContent.jsp
>>>> Mon
>>>> Jun  8 01:37:33 2009
>>>> @@ -27,24 +27,18 @@
>>>>  <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
>>>>  <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
>>>>  <%@ page import="javax.servlet.jsp.jstl.fmt.*" %>
>>>> -<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld"
>>>> prefix="stripes" %>
>>>> +<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld" prefix="s"
>>>> %>
>>>>
>>>>  <wiki:TabbedSection>
>>>>  <wiki:Tab id="findcontent" titleKey="find.tab" accesskey="s">
>>>>
>>>> -<form action="<wiki:Link format='url' jsp='Search.jsp'/>"
>>>> -       class="wikiform"
>>>> -          id="searchform2"
>>>> -         accept-charset="<wiki:ContentEncoding/>">
>>>> -
>>>> +<s:form beanclass="org.apache.wiki.action.SearchActionBean"
>>>> class="wikiform"
>>>> +    id="searchform2" acceptcharset="UTF-8">
>>>> +
>>>>  <h4><fmt:message key="find.input" /></h4>
>>>>  <p>
>>>> -    <input type="text"
>>>> -           name="query" id="query2"
>>>> -          value="<c:out value='${query}'/>"
>>>> -           size="32" />
>>>> -
>>>> -    <input type="checkbox" name="details" id="details" <c:if
>>>> test='${param.details == "on"}'>checked='checked'</c:if> />
>>>> +    <s:text name="query" id="query2" size="32" />
>>>> +    <s:checkbox name="details" id="details" />
>>>>    <fmt:message key="find.details" />
>>>>
>>>>    <select name="scope" id="scope">
>>>> @@ -55,16 +49,83 @@
>>>>      <option value="attachment:" <c:if test='${param.scope eq
>>>> "attachment:"}'>selected="selected"</c:if> ><fmt:message
>>>> key='find.scope.attach' /></option>
>>>>    </select>
>>>>
>>>> -       <input type="submit" name="ok" id="ok" value="<fmt:message
>>>> key="find.submit.find" />" />
>>>> -       <input type="submit" name="go" id="go" value="<fmt:message
>>>> key="find.submit.go" />" />
>>>> -    <input type="hidden" name="start" id="start" value="0" />
>>>> -    <input type="hidden" name="maxitems" id="maxitems" value="20" />
>>>> +    <s:submit name="search" id="ok" value="<fmt:message
>>>> key='find.submit.find' />" />
>>>> +    <s:submit name="go" id="go" value="<fmt:message
>>>> key='find.submit.go'
>>>> />" />
>>>> +    <s:hidden name="start" id="start" value="0" />
>>>> +    <s:hidden name="maxItems" id="maxitems" value="20" />
>>>>
>>>>    <span id="spin" class="spin"
>>>> style="position:absolute;display:none;"></span>
>>>>  </p>
>>>> -</form>
>>>> +</s:form>
>>>> +
>>>> +<div id="searchResult2">
>>>> +  <wiki:SearchResults>
>>>> +
>>>> +    <h4><fmt:message key="find.heading.results"><fmt:param><c:out
>>>> value="${wikiActionBean.query}" /></fmt:param></fmt:message></h4>
>>>> +    <p>
>>>> +      <fmt:message key="find.externalsearch" />
>>>> +      <a class="external" href="http://www.google.com/search?q=<c:out
>>>> value='${wikiActionBean.query}' />" title="Google Search '<c:out
>>>> value='${wikiActionBean.query}' />'" target="_blank">Google</a><img
>>>> class="outlink" src="images/out.png" alt="" />
>>>> +      |
>>>> +      <a class="external" href="
>>>> http://en.wikipedia.org/wiki/Special:Search?search=<c:out
>>>> value='${wikiActionBean.query}' />" title="Wikipedia Search '<c:out
>>>> value='${wikiActionBean.query}' />'" target="_blank">Wikipedia</a><img
>>>> class="outlink" src="images/out.png" alt="" />
>>>> +    </p>
>>>> +
>>>> +    <wiki:SetPagination start="${wikiActionBean.start}"
>>>> total="${wikiActionBean.resultsCount}" pagesize="20" maxlinks="9"
>>>> fmtkey="info.pagination" onclick="$('start').value=%s;
>>>> SearchBox.runfullsearch();" />
>>>> +
>>>> +    <div class="graphBars">
>>>> +      <div class="zebra-table">
>>>> +        <table class="wikitable">
>>>> +
>>>> +          <tr>
>>>> +             <th align="left"><fmt:message key="find.results.page"
>>>> /></th>
>>>> +             <th align="left"><fmt:message key="find.results.score"
>>>> /></th>
>>>> +          </tr>
>>>> +
>>>> +          <wiki:SearchResultIterator id="searchref"
>>>> start="${wikiActionBean.start}" maxItems="${wikiActionBean.maxItems}">
>>>> +          <tr>
>>>> +            <td><wiki:LinkTo><wiki:PageName/></wiki:LinkTo></td>
>>>> +            <td><span class="gBar"><%= searchref.getScore()
>>>> %></span></td>
>>>> +          </tr>
>>>> +
>>>> +          <c:if test="${wikiActionBean.details == 'true'}">
>>>> +  <%
>>>> +            String[] contexts = searchref.getContexts();
>>>> +            if( (contexts != null) && (contexts.length > 0) )
>>>> +            {
>>>> +  %>
>>>> +          <tr class="odd">
>>>> +            <td colspan="2">
>>>> +              <div class="fragment">
>>>> +  <%
>>>> +              for (int i = 0; i < contexts.length; i++)
>>>> +              {
>>>> +  %>
>>>> +                <%= (i > 0 ) ? "<span class='fragment_ellipsis'> ...
>>>> </span>" : ""  %>
>>>> +                <%= contexts[i]  %>
>>>> +  <%
>>>> +              }
>>>> +  %>
>>>> +               </div>
>>>> +             </td>
>>>> +           </tr>
>>>> +  <%
>>>> +            }
>>>> +  %>
>>>> +          </c:if><%-- details --%>
>>>> +        </wiki:SearchResultIterator>
>>>> +
>>>> +        <wiki:IfNoSearchResults>
>>>> +          <tr>
>>>> +            <td class="nosearchresult" colspan="2"><fmt:message
>>>> key="find.noresults" /></td>
>>>> +          </tr>
>>>> +        </wiki:IfNoSearchResults>
>>>> +
>>>> +        </table>
>>>> +      </div>
>>>> +    </div>
>>>> +    ${pagination}
>>>>
>>>> -<div id="searchResult2"><wiki:Include page="AJAXSearch.jsp" /></div>
>>>> +  </wiki:SearchResults>
>>>> +</div>
>>>>
>>>>  </wiki:Tab>
>>>>
>>>>
>>>> Modified:
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiContext.java
>>>> URL:
>>>>
>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiContext.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>
>>>>
>>>> ==============================================================================
>>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiContext.java
>>>> (original)
>>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiContext.java
>>>> Mon
>>>> Jun  8 01:37:33 2009
>>>> @@ -103,7 +103,7 @@
>>>>    public static final String    COMMENT  = HandlerInfo.getHandlerInfo(
>>>> EditActionBean.class, "comment" ).getRequestContext();
>>>>
>>>>    /** User is searching for content. */
>>>> -    public static final String    FIND     =
>>>> HandlerInfo.getHandlerInfo(
>>>> SearchActionBean.class, "find" ).getRequestContext();
>>>> +    public static final String    FIND     =
>>>> HandlerInfo.getHandlerInfo(
>>>> SearchActionBean.class, "search" ).getRequestContext();
>>>>
>>>>    /** User wishes to create a new group */
>>>>    public static final String    CREATE_GROUP =
>>>> HandlerInfo.getHandlerInfo( GroupActionBean.class, "create"
>>>> ).getRequestContext();
>>>>
>>>> Modified:
>>>>
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/action/SearchActionBean.java
>>>> URL:
>>>>
>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/action/SearchActionBean.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>
>>>>
>>>> ==============================================================================
>>>> ---
>>>>
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/action/SearchActionBean.java
>>>> (original)
>>>> +++
>>>>
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/action/SearchActionBean.java
>>>> Mon Jun  8 01:37:33 2009
>>>> @@ -21,18 +21,191 @@
>>>>
>>>>  package org.apache.wiki.action;
>>>>
>>>> -import org.apache.wiki.ui.stripes.WikiRequestContext;
>>>> +import java.util.ArrayList;
>>>> +import java.util.Collection;
>>>> +import java.util.Collections;
>>>> +import java.util.List;
>>>>
>>>>  import net.sourceforge.stripes.action.*;
>>>> +import net.sourceforge.stripes.ajax.JavaScriptResolution;
>>>> +
>>>> +import org.apache.wiki.WikiEngine;
>>>> +import org.apache.wiki.api.WikiPage;
>>>> +import org.apache.wiki.auth.AuthorizationManager;
>>>> +import org.apache.wiki.auth.permissions.PagePermission;
>>>> +import org.apache.wiki.log.Logger;
>>>> +import org.apache.wiki.log.LoggerFactory;
>>>> +import org.apache.wiki.search.SearchResult;
>>>> +import org.apache.wiki.ui.stripes.WikiRequestContext;
>>>>
>>>> +/**
>>>> + * Searches the WikiPage collection for a given wiki.
>>>> + */
>>>>  @UrlBinding( "/Search.jsp" )
>>>>  public class SearchActionBean extends AbstractActionBean
>>>>  {
>>>> +    private Logger log = LoggerFactory.getLogger("JSPWikiSearch");
>>>> +
>>>> +    public static final Collection<SearchResult> NO_RESULTS =
>>>> Collections.emptyList();
>>>> +
>>>> +    private Collection<SearchResult> m_results = NO_RESULTS;
>>>> +
>>>> +    private String m_query = null;
>>>> +
>>>> +    private int m_maxItems = 20;
>>>> +
>>>> +    private int m_start = 0;
>>>> +
>>>> +    private boolean m_details = false;
>>>> +
>>>> +    public boolean getDetails()
>>>> +    {
>>>> +        return m_details;
>>>> +    }
>>>> +
>>>> +    /**
>>>> +     * Sets the search results so that details for each result are
>>>> displayed.
>>>> +     * @param details whether details should be displayed
>>>> +     */
>>>> +    public void setDetails( boolean details )
>>>> +    {
>>>> +        m_details = details;
>>>> +    }
>>>> +
>>>> +    public int getMaxItems()
>>>> +    {
>>>> +        return m_maxItems;
>>>> +    }
>>>> +
>>>> +    public void setMaxItems( int maxItems )
>>>> +    {
>>>> +        m_maxItems = maxItems;
>>>> +    }
>>>> +
>>>> +    public int getStart()
>>>> +    {
>>>> +        return m_start;
>>>> +    }
>>>> +
>>>> +    public void setStart( int start )
>>>> +    {
>>>> +        m_start = start;
>>>> +    }
>>>> +
>>>> +    /**
>>>> +     * Returns the query string for the search.
>>>> +     *
>>>> +     * @return the query string
>>>> +     */
>>>> +    public String getQuery()
>>>> +    {
>>>> +        return m_query;
>>>> +    }
>>>> +
>>>> +    /**
>>>> +     * Returns the results of the search.
>>>> +     *
>>>> +     * @return the results
>>>> +     */
>>>> +    public Collection<SearchResult> getResults()
>>>> +    {
>>>> +        return m_results;
>>>> +    }
>>>> +
>>>> +    /**
>>>> +     * Returns the number of items returned by the current search.
>>>> +     * @return the number of items
>>>> +     */
>>>> +    public int getResultsCount()
>>>> +    {
>>>> +        return m_results.size();
>>>> +    }
>>>> +
>>>> +    /**
>>>> +     * Performs a search and returns the results as a list. For a given
>>>> WikiPage to
>>>> +     * be included in the results, the user must have permission to
>>>> view
>>>> it.
>>>> +     * If the underlying providers encounter an abnormal IOException or
>>>> other error,
>>>> +     * it will be added to the ActionBeanContext's validation messages
>>>> collection.
>>>> +     * @param query the query
>>>> +     * @return the results
>>>> +     */
>>>> +    private List<SearchResult> doSearch( String query )
>>>> +    {
>>>> +        log.info("Searching with query '"+ query + "'.");
>>>> +        WikiEngine engine = getContext().getEngine();
>>>> +        AuthorizationManager mgr = engine.getAuthorizationManager();
>>>> +
>>>> +        //
>>>> +        //  Filter down to only those that we actually have a
>>>> permission
>>>> to view
>>>> +        //
>>>> +        List<SearchResult> filteredResults = new
>>>> ArrayList<SearchResult>();
>>>> +        try
>>>> +        {
>>>> +            List<SearchResult> results = engine.findPages( query );
>>>> +            for( SearchResult result : results )
>>>> +            {
>>>> +                WikiPage page = result.getPage();
>>>> +                PagePermission permission = new PagePermission( page,
>>>> PagePermission.VIEW_ACTION );
>>>> +                try
>>>> +                {
>>>> +                    if( mgr.checkPermission(
>>>> getContext().getWikiSession(), permission ) )
>>>> +                    {
>>>> +                        filteredResults.add( result );
>>>> +                    }
>>>> +                }
>>>> +                catch( Exception e ) { log.error( "Searching for page "
>>>> +
>>>> page, e ); }
>>>> +            }
>>>> +        }
>>>> +        catch( Exception e )
>>>> +        {
>>>> +            log.debug( "Could not search using query '" + query + "'.",
>>>> e
>>>> );
>>>> +            Message message = new SimpleMessage( e.getMessage() );
>>>> +            getContext().getMessages().add( message );
>>>> +            e.printStackTrace();
>>>> +        }
>>>> +        return filteredResults;
>>>> +    }
>>>> +
>>>> +    /**
>>>> +     * Sets the query string for the search.
>>>> +     *
>>>> +     * @param query the query string
>>>> +     */
>>>> +    public void setQuery( String query )
>>>> +    {
>>>> +        m_query = query;
>>>> +    }
>>>> +
>>>> +    /**
>>>> +     * Searches the wiki using the query string set for this
>>>> +     * ActionBean. Search results are made available to callers via the
>>>> +     * {@link #getResults()} method (and EL expression
>>>> +     * <code>$wikiActionBean.results</code>).
>>>> +     *
>>>> +     * @return always returns a {@link ForwardResolution} to
>>>> +     *         <code>/Search.jsp</code>.
>>>> +     */
>>>>    @DefaultHandler
>>>> -    @HandlesEvent( "find" )
>>>> +    @HandlesEvent( "search" )
>>>>    @WikiRequestContext( "find" )
>>>> -    public Resolution view()
>>>> +    public Resolution search()
>>>>    {
>>>> +        m_results = m_query == null ? NO_RESULTS : doSearch( m_query );
>>>>        return new ForwardResolution( "/Search.jsp" );
>>>>    }
>>>> +
>>>> +    /**
>>>> +     * Using AJAX, searches a specified wiki space using the query
>>>> string
>>>> set for this
>>>> +     * ActionBean. Results are streamed back to the client as an array
>>>> of
>>>> JSON-encoded
>>>> +     * SearchResult objects.
>>>> +     *
>>>> +     * @return always returns a {@link JavaScriptResolution} containing
>>>> the
>>>> +     * results; this may be a zero-length array
>>>> +     */
>>>> +    @HandlesEvent( "ajaxSearch" )
>>>> +    public Resolution ajaxSearch()
>>>> +    {
>>>> +        m_results = m_query == null ? NO_RESULTS : doSearch( m_query );
>>>> +        return new JavaScriptResolution( m_results );
>>>> +    }
>>>>  }
>>>>
>>>> Modified:
>>>>
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IfNoSearchResultsTag.java
>>>> URL:
>>>>
>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IfNoSearchResultsTag.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>
>>>>
>>>> ==============================================================================
>>>> ---
>>>>
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IfNoSearchResultsTag.java
>>>> (original)
>>>> +++
>>>>
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IfNoSearchResultsTag.java
>>>> Mon Jun  8 01:37:33 2009
>>>> @@ -22,8 +22,8 @@
>>>>
>>>>  import java.io.IOException;
>>>>  import java.util.Collection;
>>>> -import javax.servlet.jsp.PageContext;
>>>>
>>>> +import org.apache.wiki.action.SearchActionBean;
>>>>  import org.apache.wiki.search.SearchResult;
>>>>
>>>>  /**
>>>> @@ -36,17 +36,18 @@
>>>>  {
>>>>    private static final long serialVersionUID = 0L;
>>>>
>>>> -    @SuppressWarnings("unchecked")
>>>>    public final int doWikiStartTag()
>>>>        throws IOException
>>>>    {
>>>> -        Collection<SearchResult> list =
>>>> (Collection<SearchResult>)pageContext.getAttribute( "searchresults",
>>>> -
>>>>  PageContext.REQUEST_SCOPE );
>>>> -        if( list == null || list.size() == 0 )
>>>> -        {
>>>> -            return EVAL_BODY_INCLUDE;
>>>> +        if ( m_wikiActionBean != null && m_wikiActionBean instanceof
>>>> SearchActionBean )
>>>> +        {
>>>> +            boolean emptyQuery =
>>>> ((SearchActionBean)m_wikiActionBean).getQuery() == null;
>>>> +            Collection<SearchResult> results =
>>>> ((SearchActionBean)m_wikiActionBean).getResults();
>>>> +            if ( emptyQuery || results.size() > 0 )
>>>> +            {
>>>> +                return SKIP_BODY;
>>>> +            }
>>>>        }
>>>> -
>>>> -        return SKIP_BODY;
>>>> +        return EVAL_BODY_INCLUDE;
>>>>    }
>>>>  }
>>>>
>>>> Modified:
>>>>
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultIteratorTag.java
>>>> URL:
>>>>
>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultIteratorTag.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>
>>>>
>>>> ==============================================================================
>>>> ---
>>>>
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultIteratorTag.java
>>>> (original)
>>>> +++
>>>>
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultIteratorTag.java
>>>> Mon Jun  8 01:37:33 2009
>>>> @@ -20,12 +20,12 @@
>>>>  */
>>>>  package org.apache.wiki.tags;
>>>>
>>>> -import java.util.ArrayList;
>>>>  import java.util.Collection;
>>>>
>>>> -import javax.servlet.jsp.PageContext;
>>>> -
>>>> +import org.apache.wiki.action.SearchActionBean;
>>>> +import org.apache.wiki.action.WikiActionBean;
>>>>  import org.apache.wiki.search.SearchResult;
>>>> +import org.apache.wiki.ui.stripes.WikiInterceptor;
>>>>
>>>>  /**
>>>>  * Iterator tag for the current search results, as identified by a
>>>> @@ -36,19 +36,17 @@
>>>>    private static final long serialVersionUID = 1L;
>>>>
>>>>    /**
>>>> -     * \ Returns the list of SearchResults to iterate over.
>>>> +     * Returns the list of SearchResults to iterate over.
>>>>     */
>>>>    @Override
>>>> -    @SuppressWarnings( "unchecked" )
>>>>    protected Collection<SearchResult> initItems()
>>>>    {
>>>> -        Collection<SearchResult> results = (Collection<SearchResult>)
>>>> pageContext.getAttribute( "searchresults",
>>>> -
>>>>                     PageContext.REQUEST_SCOPE );
>>>> -        if( results == null )
>>>> +        WikiActionBean actionBean = WikiInterceptor.findActionBean(
>>>> pageContext );
>>>> +        if ( actionBean != null && actionBean instanceof
>>>> SearchActionBean
>>>> )
>>>>        {
>>>> -            return new ArrayList<SearchResult>();
>>>> +            return ((SearchActionBean)actionBean).getResults();
>>>>        }
>>>> -        return results;
>>>> +        return SearchActionBean.NO_RESULTS;
>>>>    }
>>>>
>>>>    /**
>>>>
>>>> Modified:
>>>>
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsSizeTag.java
>>>> URL:
>>>>
>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsSizeTag.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>
>>>>
>>>> ==============================================================================
>>>> ---
>>>>
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsSizeTag.java
>>>> (original)
>>>> +++
>>>>
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsSizeTag.java
>>>> Mon Jun  8 01:37:33 2009
>>>> @@ -22,8 +22,8 @@
>>>>
>>>>  import java.io.IOException;
>>>>  import java.util.Collection;
>>>> -import javax.servlet.jsp.PageContext;
>>>>
>>>> +import org.apache.wiki.action.SearchActionBean;
>>>>  import org.apache.wiki.search.SearchResult;
>>>>
>>>>  /**
>>>> @@ -37,17 +37,14 @@
>>>>  {
>>>>    private static final long serialVersionUID = 0L;
>>>>
>>>> -    @SuppressWarnings("unchecked")
>>>>    public final int doWikiStartTag()
>>>>        throws IOException
>>>>    {
>>>> -        Collection<SearchResult> list =
>>>> (Collection<SearchResult>)pageContext.getAttribute( "searchresults",
>>>> -
>>>>  PageContext.REQUEST_SCOPE );
>>>> -        if( list != null )
>>>> +        if ( m_wikiActionBean != null && m_wikiActionBean instanceof
>>>> SearchActionBean )
>>>>        {
>>>> -            pageContext.getOut().print( list.size() );
>>>> +            Collection<SearchResult> results =
>>>> ((SearchActionBean)m_wikiActionBean).getResults();
>>>> +            pageContext.getOut().print( results.size() );
>>>>        }
>>>> -
>>>>        return SKIP_BODY;
>>>>    }
>>>>  }
>>>>
>>>> Modified:
>>>>
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsTag.java
>>>> URL:
>>>>
>>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsTag.java?rev=782495&r1=782494&r2=782495&view=diff
>>>>
>>>>
>>>> ==============================================================================
>>>> ---
>>>>
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsTag.java
>>>> (original)
>>>> +++
>>>>
>>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsTag.java
>>>> Mon Jun  8 01:37:33 2009
>>>> @@ -21,10 +21,10 @@
>>>>  package org.apache.wiki.tags;
>>>>
>>>>  import java.io.IOException;
>>>> -import java.util.Collection;
>>>> +
>>>>  import javax.servlet.jsp.PageContext;
>>>>
>>>> -import org.apache.wiki.search.SearchResult;
>>>> +import org.apache.wiki.action.SearchActionBean;
>>>>
>>>>  /**
>>>>  *  Includes the body content, if there are any search results.
>>>> @@ -36,16 +36,16 @@
>>>>  {
>>>>    private static final long serialVersionUID = 0L;
>>>>
>>>> -    @SuppressWarnings("unchecked")
>>>>    public final int doWikiStartTag()
>>>>        throws IOException
>>>>    {
>>>> -        Collection<SearchResult> list =
>>>> (Collection<SearchResult>)pageContext.getAttribute( "searchresults",
>>>> -
>>>>  PageContext.REQUEST_SCOPE );
>>>> -
>>>> -        if( list != null )
>>>> +        if ( m_wikiActionBean != null && m_wikiActionBean instanceof
>>>> SearchActionBean )
>>>>        {
>>>> -            return EVAL_BODY_INCLUDE;
>>>> +            boolean emptyQuery =
>>>> ((SearchActionBean)m_wikiActionBean).getQuery() == null;
>>>> +            if ( !emptyQuery )
>>>> +            {
>>>> +                return EVAL_BODY_INCLUDE;
>>>> +            }
>>>>        }
>>>>
>>>>        String message = (String)pageContext.getAttribute( "err",
>>>>
>>>>
>>>>
>>>>
>>>
>

Re: svn commit: r782495 - in /incubator/jspwiki/trunk/src: WebContent/ WebContent/scripts/ WebContent/templates/default/ java/org/apache/wiki/ java/org/apache/wiki/action/ java/org/apache/wiki/tags/

Posted by Janne Jalkanen <ja...@ecyrd.com>.
Reminds me - the JS code used to call Ajax routines is disgustingly  
loathsome and makes my eyes bleed and my stomach retch.  Can we  
upgrade to a newer Mootools lib (1.2.2, I think) and switch to  
Request.JSON and create a JSONFactory or an extension for creating our  
AJAX requests?

Something like wiki.json( "Search", "ajaxSearch", { param1 :  
value1, ... }, callback(resultobj,resulttext) ); would be nice. This  
would construct the URL to SearchActionBean, method ajaxSearch, with  
the given params.

/Janne

On 8 Jun 2009, at 21:52, Andrew Jaquith wrote:

> It will fix this one -- but only after we've hooked it up to the
> client JavaScript. Should not take long.
>
> On Mon, Jun 8, 2009 at 2:44 PM, Harry Metske<ha...@gmail.com>  
> wrote:
>> Andrew,
>>
>> should this patch have fixed
>> https://issues.apache.org/jira/browse/JSPWIKI-510 (only for 3.0 of  
>> course) ?
>>
>> Harry
>>
>> 2009/6/8 <aj...@apache.org>
>>
>>> Author: ajaquith
>>> Date: Mon Jun  8 01:37:33 2009
>>> New Revision: 782495
>>>
>>> URL: http://svn.apache.org/viewvc?rev=782495&view=rev
>>> Log:
>>> Search.jsp migrated to Stripes. SearchActionBean now provides  
>>> searching
>>> logic, including an ajaxSearch() method that filters results  
>>> correctly (this
>>> is not hooked up to the client JavaScript yet, but it should be
>>> straightforward to do). Still some i18n cleanup to do.
>>>
>>> Modified:
>>>    incubator/jspwiki/trunk/src/WebContent/Search.jsp
>>>    incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-common.js
>>>    incubator/jspwiki/trunk/src/WebContent/templates/default/ 
>>> FindContent.jsp
>>>    incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiContext.java
>>>
>>>  incubator/jspwiki/trunk/src/java/org/apache/wiki/action/ 
>>> SearchActionBean.java
>>>
>>>  incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>> IfNoSearchResultsTag.java
>>>
>>>  incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>> SearchResultIteratorTag.java
>>>
>>>  incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>> SearchResultsSizeTag.java
>>>
>>>  incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>> SearchResultsTag.java
>>>
>>> Modified: incubator/jspwiki/trunk/src/WebContent/Search.jsp
>>> URL:
>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/WebContent/Search.jsp?rev=782495&r1=782494&r2=782495&view=diff
>>>
>>> = 
>>> = 
>>> = 
>>> = 
>>> = 
>>> = 
>>> = 
>>> = 
>>> = 
>>> = 
>>> ====================================================================
>>> --- incubator/jspwiki/trunk/src/WebContent/Search.jsp (original)
>>> +++ incubator/jspwiki/trunk/src/WebContent/Search.jsp Mon Jun  8  
>>> 01:37:33
>>> 2009
>>> @@ -18,108 +18,12 @@
>>>     specific language governing permissions and limitations
>>>     under the License.
>>>  --%>
>>> -<%@ page import="org.apache.wiki.log.Logger" %>
>>> -<%@ page import="org.apache.wiki.log.LoggerFactory" %>
>>> -<%@ page import="org.apache.wiki.*" %>
>>> -<%@ page import="org.apache.wiki.auth.*" %>
>>> -<%@ page import="org.apache.wiki.auth.permissions.*" %>
>>> -<%@ page import="java.util.*" %>
>>> +<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld"  
>>> prefix="s" %>
>>>  <%@ page errorPage="/Error.jsp" %>
>>> -<%@ page import="org.apache.wiki.search.*" %>
>>> -<%@ taglib uri="http://jakarta.apache.org/jspwiki.tld"  
>>> prefix="wiki" %>
>>> -<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld"
>>> prefix="stripes" %>
>>> -<%@ page import="org.apache.wiki.util.TextUtil" %>
>>> -<%@ page import="org.apache.wiki.api.WikiPage" %>
>>> -<stripes:useActionBean  
>>> beanclass="org.apache.wiki.action.SearchActionBean"
>>> event="find" id="wikiActionBean" />
>>> +<s:useActionBean  
>>> beanclass="org.apache.wiki.action.SearchActionBean"
>>> event="search" executeResolution="true" id="wikiActionBean" />
>>> +<s:layout-render name="${templates['DefaultLayout.jsp']}">
>>> +  <s:layout-component name="content">
>>> +      <jsp:include page="${templates['FindContent.jsp']}" />
>>> +  </s:layout-component>
>>> +</s:layout-render>
>>>
>>> -<%!
>>> -    Logger log = LoggerFactory.getLogger("JSPWikiSearch");
>>> -%>
>>> -
>>> -<%
>>> -    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
>>> -    // Create wiki context and check for authorization
>>> -    WikiContext wikiContext = wiki.createContext( request,
>>> WikiContext.FIND );
>>> -    String pagereq = wikiContext.getPage().getName();
>>> -
>>> -    // Get the search results
>>> -    Collection list = null;
>>> -    String query = request.getParameter( "query");
>>> -    String go    = request.getParameter("go");
>>> -
>>> -    if( query != null )
>>> -    {
>>> -        log.info("Searching for string "+query);
>>> -
>>> -        try
>>> -        {
>>> -            list = wiki.findPages( query );
>>> -
>>> -            //
>>> -            //  Filter down to only those that we actually have a
>>> permission to view
>>> -            //
>>> -            AuthorizationManager mgr =  
>>> wiki.getAuthorizationManager();
>>> -
>>> -            ArrayList filteredList = new ArrayList();
>>> -
>>> -            for( Iterator i = list.iterator(); i.hasNext(); )
>>> -            {
>>> -                SearchResult r = (SearchResult)i.next();
>>> -
>>> -                WikiPage p = r.getPage();
>>> -
>>> -                PagePermission pp = new PagePermission( p,
>>> PagePermission.VIEW_ACTION );
>>> -
>>> -                try
>>> -                {
>>> -                     
>>> if( mgr.checkPermission( wikiContext.getWikiSession(),
>>> pp ) )
>>> -                    {
>>> -                        filteredList.add( r );
>>> -                    }
>>> -                }
>>> -                catch( Exception e ) { log.error( "Searching for  
>>> page "+p,
>>> e ); }
>>> -            }
>>> -
>>> -            pageContext.setAttribute( "searchresults",
>>> -                                      filteredList,
>>> -                                      PageContext.REQUEST_SCOPE );
>>> -        }
>>> -        catch( Exception e )
>>> -        {
>>> -             
>>> wikiContext.getWikiSession().addMessage( e.getMessage() );
>>> -        }
>>> -
>>> -        query = TextUtil.replaceEntities( query );
>>> -
>>> -        pageContext.setAttribute( "query",
>>> -                                  query,
>>> -                                  PageContext.REQUEST_SCOPE );
>>> -
>>> -        //
>>> -        //  Did the user click on "go"?
>>> -        //
>>> -        if( go != null )
>>> -        {
>>> -            if( list != null && list.size() > 0 )
>>> -            {
>>> -                SearchResult sr = (SearchResult)  
>>> list.iterator().next();
>>> -
>>> -                WikiPage wikiPage = sr.getPage();
>>> -
>>> -                String url =  
>>> wikiContext.getViewURL( wikiPage.getName() );
>>> -
>>> -                response.sendRedirect( url );
>>> -
>>> -                return;
>>> -            }
>>> -        }
>>> -    }
>>> -
>>> -    // Set the content type and include the response content
>>> -    response.setContentType("text/html;
>>> charset="+wiki.getContentEncoding() );
>>> -    String contentPage =  
>>> wiki.getTemplateManager().findJSP( pageContext,
>>> -
>>>  wikiContext.getTemplate(),
>>> -
>>>  "ViewTemplate.jsp" );
>>> -%><wiki:Include page="<%=contentPage%>" /><%
>>> -    log.debug("SEARCH COMPLETE");
>>> -%>
>>>
>>> Modified: incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki- 
>>> common.js
>>> URL:
>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-common.js?rev=782495&r1=782494&r2=782495&view=diff
>>>
>>> = 
>>> = 
>>> = 
>>> = 
>>> = 
>>> = 
>>> = 
>>> = 
>>> = 
>>> = 
>>> ====================================================================
>>> --- incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-common.js
>>> (original)
>>> +++ incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki- 
>>> common.js Mon
>>> Jun  8 01:37:33 2009
>>> @@ -931,9 +931,9 @@
>>>                        if (option.value == match) option.selected  
>>> = true;
>>>                });
>>>
>>> -               new Ajax(Wiki.TemplateUrl+'AJAXSearch.jsp', {
>>> -                       postBody: $('searchform2').toQueryString(),
>>> -                       update: 'searchResult2',
>>> +               new Ajax(Wiki.BasePath+'Search.action', {
>>> +                       postBody:
>>> "ajaxSearch=&"+$('searchform2').toQueryString(),
>>> +                       update: 'searchResult2',
>>>                        method: 'post',
>>>                        onComplete: function() {
>>>                                $('spin').hide();
>>>
>>> Modified:
>>> incubator/jspwiki/trunk/src/WebContent/templates/default/ 
>>> FindContent.jsp
>>> URL:
>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/WebContent/templates/default/FindContent.jsp?rev=782495&r1=782494&r2=782495&view=diff
>>>
>>> = 
>>> = 
>>> = 
>>> = 
>>> = 
>>> = 
>>> = 
>>> = 
>>> = 
>>> = 
>>> ====================================================================
>>> ---
>>> incubator/jspwiki/trunk/src/WebContent/templates/default/ 
>>> FindContent.jsp
>>> (original)
>>> +++
>>> incubator/jspwiki/trunk/src/WebContent/templates/default/ 
>>> FindContent.jsp Mon
>>> Jun  8 01:37:33 2009
>>> @@ -27,24 +27,18 @@
>>>  <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
>>>  <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
>>>  <%@ page import="javax.servlet.jsp.jstl.fmt.*" %>
>>> -<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld"
>>> prefix="stripes" %>
>>> +<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld"  
>>> prefix="s" %>
>>>
>>>  <wiki:TabbedSection>
>>>  <wiki:Tab id="findcontent" titleKey="find.tab" accesskey="s">
>>>
>>> -<form action="<wiki:Link format='url' jsp='Search.jsp'/>"
>>> -       class="wikiform"
>>> -          id="searchform2"
>>> -         accept-charset="<wiki:ContentEncoding/>">
>>> -
>>> +<s:form beanclass="org.apache.wiki.action.SearchActionBean"
>>> class="wikiform"
>>> +    id="searchform2" acceptcharset="UTF-8">
>>> +
>>>   <h4><fmt:message key="find.input" /></h4>
>>>   <p>
>>> -    <input type="text"
>>> -           name="query" id="query2"
>>> -          value="<c:out value='${query}'/>"
>>> -           size="32" />
>>> -
>>> -    <input type="checkbox" name="details" id="details" <c:if
>>> test='${param.details == "on"}'>checked='checked'</c:if> />
>>> +    <s:text name="query" id="query2" size="32" />
>>> +    <s:checkbox name="details" id="details" />
>>>     <fmt:message key="find.details" />
>>>
>>>     <select name="scope" id="scope">
>>> @@ -55,16 +49,83 @@
>>>       <option value="attachment:" <c:if test='${param.scope eq
>>> "attachment:"}'>selected="selected"</c:if> ><fmt:message
>>> key='find.scope.attach' /></option>
>>>     </select>
>>>
>>> -       <input type="submit" name="ok" id="ok" value="<fmt:message
>>> key="find.submit.find" />" />
>>> -       <input type="submit" name="go" id="go" value="<fmt:message
>>> key="find.submit.go" />" />
>>> -    <input type="hidden" name="start" id="start" value="0" />
>>> -    <input type="hidden" name="maxitems" id="maxitems"  
>>> value="20" />
>>> +    <s:submit name="search" id="ok" value="<fmt:message
>>> key='find.submit.find' />" />
>>> +    <s:submit name="go" id="go" value="<fmt:message  
>>> key='find.submit.go'
>>> />" />
>>> +    <s:hidden name="start" id="start" value="0" />
>>> +    <s:hidden name="maxItems" id="maxitems" value="20" />
>>>
>>>     <span id="spin" class="spin"
>>> style="position:absolute;display:none;"></span>
>>>   </p>
>>> -</form>
>>> +</s:form>
>>> +
>>> +<div id="searchResult2">
>>> +  <wiki:SearchResults>
>>> +
>>> +    <h4><fmt:message key="find.heading.results"><fmt:param><c:out
>>> value="${wikiActionBean.query}" /></fmt:param></fmt:message></h4>
>>> +    <p>
>>> +      <fmt:message key="find.externalsearch" />
>>> +      <a class="external" href="http://www.google.com/search? 
>>> q=<c:out
>>> value='${wikiActionBean.query}' />" title="Google Search '<c:out
>>> value='${wikiActionBean.query}' />'" target="_blank">Google</a><img
>>> class="outlink" src="images/out.png" alt="" />
>>> +      |
>>> +      <a class="external" href="
>>> http://en.wikipedia.org/wiki/Special:Search?search=<c:out
>>> value='${wikiActionBean.query}' />" title="Wikipedia Search '<c:out
>>> value='${wikiActionBean.query}' />'" target="_blank">Wikipedia</ 
>>> a><img
>>> class="outlink" src="images/out.png" alt="" />
>>> +    </p>
>>> +
>>> +    <wiki:SetPagination start="${wikiActionBean.start}"
>>> total="${wikiActionBean.resultsCount}" pagesize="20" maxlinks="9"
>>> fmtkey="info.pagination" onclick="$('start').value=%s;
>>> SearchBox.runfullsearch();" />
>>> +
>>> +    <div class="graphBars">
>>> +      <div class="zebra-table">
>>> +        <table class="wikitable">
>>> +
>>> +          <tr>
>>> +             <th align="left"><fmt:message  
>>> key="find.results.page" /></th>
>>> +             <th align="left"><fmt:message key="find.results.score"
>>> /></th>
>>> +          </tr>
>>> +
>>> +          <wiki:SearchResultIterator id="searchref"
>>> start="${wikiActionBean.start}" maxItems="$ 
>>> {wikiActionBean.maxItems}">
>>> +          <tr>
>>> +            <td><wiki:LinkTo><wiki:PageName/></wiki:LinkTo></td>
>>> +            <td><span class="gBar"><%= searchref.getScore() %></ 
>>> span></td>
>>> +          </tr>
>>> +
>>> +          <c:if test="${wikiActionBean.details == 'true'}">
>>> +  <%
>>> +            String[] contexts = searchref.getContexts();
>>> +            if( (contexts != null) && (contexts.length > 0) )
>>> +            {
>>> +  %>
>>> +          <tr class="odd">
>>> +            <td colspan="2">
>>> +              <div class="fragment">
>>> +  <%
>>> +              for (int i = 0; i < contexts.length; i++)
>>> +              {
>>> +  %>
>>> +                <%= (i > 0 ) ? "<span  
>>> class='fragment_ellipsis'> ...
>>> </span>" : ""  %>
>>> +                <%= contexts[i]  %>
>>> +  <%
>>> +              }
>>> +  %>
>>> +               </div>
>>> +             </td>
>>> +           </tr>
>>> +  <%
>>> +            }
>>> +  %>
>>> +          </c:if><%-- details --%>
>>> +        </wiki:SearchResultIterator>
>>> +
>>> +        <wiki:IfNoSearchResults>
>>> +          <tr>
>>> +            <td class="nosearchresult" colspan="2"><fmt:message
>>> key="find.noresults" /></td>
>>> +          </tr>
>>> +        </wiki:IfNoSearchResults>
>>> +
>>> +        </table>
>>> +      </div>
>>> +    </div>
>>> +    ${pagination}
>>>
>>> -<div id="searchResult2"><wiki:Include page="AJAXSearch.jsp" /></ 
>>> div>
>>> +  </wiki:SearchResults>
>>> +</div>
>>>
>>>  </wiki:Tab>
>>>
>>>
>>> Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/ 
>>> WikiContext.java
>>> URL:
>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiContext.java?rev=782495&r1=782494&r2=782495&view=diff
>>>
>>> = 
>>> = 
>>> = 
>>> = 
>>> = 
>>> = 
>>> = 
>>> = 
>>> = 
>>> = 
>>> ====================================================================
>>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/ 
>>> WikiContext.java
>>> (original)
>>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/ 
>>> WikiContext.java Mon
>>> Jun  8 01:37:33 2009
>>> @@ -103,7 +103,7 @@
>>>     public static final String    COMMENT  =  
>>> HandlerInfo.getHandlerInfo(
>>> EditActionBean.class, "comment" ).getRequestContext();
>>>
>>>     /** User is searching for content. */
>>> -    public static final String    FIND     =  
>>> HandlerInfo.getHandlerInfo(
>>> SearchActionBean.class, "find" ).getRequestContext();
>>> +    public static final String    FIND     =  
>>> HandlerInfo.getHandlerInfo(
>>> SearchActionBean.class, "search" ).getRequestContext();
>>>
>>>     /** User wishes to create a new group */
>>>     public static final String    CREATE_GROUP =
>>> HandlerInfo.getHandlerInfo( GroupActionBean.class, "create"
>>> ).getRequestContext();
>>>
>>> Modified:
>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/action/ 
>>> SearchActionBean.java
>>> URL:
>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/action/SearchActionBean.java?rev=782495&r1=782494&r2=782495&view=diff
>>>
>>> = 
>>> = 
>>> = 
>>> = 
>>> = 
>>> = 
>>> = 
>>> = 
>>> = 
>>> = 
>>> ====================================================================
>>> ---
>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/action/ 
>>> SearchActionBean.java
>>> (original)
>>> +++
>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/action/ 
>>> SearchActionBean.java
>>> Mon Jun  8 01:37:33 2009
>>> @@ -21,18 +21,191 @@
>>>
>>>  package org.apache.wiki.action;
>>>
>>> -import org.apache.wiki.ui.stripes.WikiRequestContext;
>>> +import java.util.ArrayList;
>>> +import java.util.Collection;
>>> +import java.util.Collections;
>>> +import java.util.List;
>>>
>>>  import net.sourceforge.stripes.action.*;
>>> +import net.sourceforge.stripes.ajax.JavaScriptResolution;
>>> +
>>> +import org.apache.wiki.WikiEngine;
>>> +import org.apache.wiki.api.WikiPage;
>>> +import org.apache.wiki.auth.AuthorizationManager;
>>> +import org.apache.wiki.auth.permissions.PagePermission;
>>> +import org.apache.wiki.log.Logger;
>>> +import org.apache.wiki.log.LoggerFactory;
>>> +import org.apache.wiki.search.SearchResult;
>>> +import org.apache.wiki.ui.stripes.WikiRequestContext;
>>>
>>> +/**
>>> + * Searches the WikiPage collection for a given wiki.
>>> + */
>>>  @UrlBinding( "/Search.jsp" )
>>>  public class SearchActionBean extends AbstractActionBean
>>>  {
>>> +    private Logger log = LoggerFactory.getLogger("JSPWikiSearch");
>>> +
>>> +    public static final Collection<SearchResult> NO_RESULTS =
>>> Collections.emptyList();
>>> +
>>> +    private Collection<SearchResult> m_results = NO_RESULTS;
>>> +
>>> +    private String m_query = null;
>>> +
>>> +    private int m_maxItems = 20;
>>> +
>>> +    private int m_start = 0;
>>> +
>>> +    private boolean m_details = false;
>>> +
>>> +    public boolean getDetails()
>>> +    {
>>> +        return m_details;
>>> +    }
>>> +
>>> +    /**
>>> +     * Sets the search results so that details for each result are
>>> displayed.
>>> +     * @param details whether details should be displayed
>>> +     */
>>> +    public void setDetails( boolean details )
>>> +    {
>>> +        m_details = details;
>>> +    }
>>> +
>>> +    public int getMaxItems()
>>> +    {
>>> +        return m_maxItems;
>>> +    }
>>> +
>>> +    public void setMaxItems( int maxItems )
>>> +    {
>>> +        m_maxItems = maxItems;
>>> +    }
>>> +
>>> +    public int getStart()
>>> +    {
>>> +        return m_start;
>>> +    }
>>> +
>>> +    public void setStart( int start )
>>> +    {
>>> +        m_start = start;
>>> +    }
>>> +
>>> +    /**
>>> +     * Returns the query string for the search.
>>> +     *
>>> +     * @return the query string
>>> +     */
>>> +    public String getQuery()
>>> +    {
>>> +        return m_query;
>>> +    }
>>> +
>>> +    /**
>>> +     * Returns the results of the search.
>>> +     *
>>> +     * @return the results
>>> +     */
>>> +    public Collection<SearchResult> getResults()
>>> +    {
>>> +        return m_results;
>>> +    }
>>> +
>>> +    /**
>>> +     * Returns the number of items returned by the current search.
>>> +     * @return the number of items
>>> +     */
>>> +    public int getResultsCount()
>>> +    {
>>> +        return m_results.size();
>>> +    }
>>> +
>>> +    /**
>>> +     * Performs a search and returns the results as a list. For a  
>>> given
>>> WikiPage to
>>> +     * be included in the results, the user must have permission  
>>> to view
>>> it.
>>> +     * If the underlying providers encounter an abnormal  
>>> IOException or
>>> other error,
>>> +     * it will be added to the ActionBeanContext's validation  
>>> messages
>>> collection.
>>> +     * @param query the query
>>> +     * @return the results
>>> +     */
>>> +    private List<SearchResult> doSearch( String query )
>>> +    {
>>> +        log.info("Searching with query '"+ query + "'.");
>>> +        WikiEngine engine = getContext().getEngine();
>>> +        AuthorizationManager mgr =  
>>> engine.getAuthorizationManager();
>>> +
>>> +        //
>>> +        //  Filter down to only those that we actually have a  
>>> permission
>>> to view
>>> +        //
>>> +        List<SearchResult> filteredResults = new
>>> ArrayList<SearchResult>();
>>> +        try
>>> +        {
>>> +            List<SearchResult> results = engine.findPages( query );
>>> +            for( SearchResult result : results )
>>> +            {
>>> +                WikiPage page = result.getPage();
>>> +                PagePermission permission = new  
>>> PagePermission( page,
>>> PagePermission.VIEW_ACTION );
>>> +                try
>>> +                {
>>> +                    if( mgr.checkPermission(
>>> getContext().getWikiSession(), permission ) )
>>> +                    {
>>> +                        filteredResults.add( result );
>>> +                    }
>>> +                }
>>> +                catch( Exception e ) { log.error( "Searching for  
>>> page " +
>>> page, e ); }
>>> +            }
>>> +        }
>>> +        catch( Exception e )
>>> +        {
>>> +            log.debug( "Could not search using query '" + query +  
>>> "'.", e
>>> );
>>> +            Message message = new SimpleMessage( e.getMessage() );
>>> +            getContext().getMessages().add( message );
>>> +            e.printStackTrace();
>>> +        }
>>> +        return filteredResults;
>>> +    }
>>> +
>>> +    /**
>>> +     * Sets the query string for the search.
>>> +     *
>>> +     * @param query the query string
>>> +     */
>>> +    public void setQuery( String query )
>>> +    {
>>> +        m_query = query;
>>> +    }
>>> +
>>> +    /**
>>> +     * Searches the wiki using the query string set for this
>>> +     * ActionBean. Search results are made available to callers  
>>> via the
>>> +     * {@link #getResults()} method (and EL expression
>>> +     * <code>$wikiActionBean.results</code>).
>>> +     *
>>> +     * @return always returns a {@link ForwardResolution} to
>>> +     *         <code>/Search.jsp</code>.
>>> +     */
>>>     @DefaultHandler
>>> -    @HandlesEvent( "find" )
>>> +    @HandlesEvent( "search" )
>>>     @WikiRequestContext( "find" )
>>> -    public Resolution view()
>>> +    public Resolution search()
>>>     {
>>> +        m_results = m_query == null ? NO_RESULTS :  
>>> doSearch( m_query );
>>>         return new ForwardResolution( "/Search.jsp" );
>>>     }
>>> +
>>> +    /**
>>> +     * Using AJAX, searches a specified wiki space using the  
>>> query string
>>> set for this
>>> +     * ActionBean. Results are streamed back to the client as an  
>>> array of
>>> JSON-encoded
>>> +     * SearchResult objects.
>>> +     *
>>> +     * @return always returns a {@link JavaScriptResolution}  
>>> containing
>>> the
>>> +     * results; this may be a zero-length array
>>> +     */
>>> +    @HandlesEvent( "ajaxSearch" )
>>> +    public Resolution ajaxSearch()
>>> +    {
>>> +        m_results = m_query == null ? NO_RESULTS :  
>>> doSearch( m_query );
>>> +        return new JavaScriptResolution( m_results );
>>> +    }
>>>  }
>>>
>>> Modified:
>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>> IfNoSearchResultsTag.java
>>> URL:
>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IfNoSearchResultsTag.java?rev=782495&r1=782494&r2=782495&view=diff
>>>
>>> = 
>>> = 
>>> = 
>>> = 
>>> = 
>>> = 
>>> = 
>>> = 
>>> = 
>>> = 
>>> ====================================================================
>>> ---
>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>> IfNoSearchResultsTag.java
>>> (original)
>>> +++
>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>> IfNoSearchResultsTag.java
>>> Mon Jun  8 01:37:33 2009
>>> @@ -22,8 +22,8 @@
>>>
>>>  import java.io.IOException;
>>>  import java.util.Collection;
>>> -import javax.servlet.jsp.PageContext;
>>>
>>> +import org.apache.wiki.action.SearchActionBean;
>>>  import org.apache.wiki.search.SearchResult;
>>>
>>>  /**
>>> @@ -36,17 +36,18 @@
>>>  {
>>>     private static final long serialVersionUID = 0L;
>>>
>>> -    @SuppressWarnings("unchecked")
>>>     public final int doWikiStartTag()
>>>         throws IOException
>>>     {
>>> -        Collection<SearchResult> list =
>>> (Collection<SearchResult>)pageContext.getAttribute( "searchresults",
>>> -
>>>  PageContext.REQUEST_SCOPE );
>>> -        if( list == null || list.size() == 0 )
>>> -        {
>>> -            return EVAL_BODY_INCLUDE;
>>> +        if ( m_wikiActionBean != null && m_wikiActionBean  
>>> instanceof
>>> SearchActionBean )
>>> +        {
>>> +            boolean emptyQuery =
>>> ((SearchActionBean)m_wikiActionBean).getQuery() == null;
>>> +            Collection<SearchResult> results =
>>> ((SearchActionBean)m_wikiActionBean).getResults();
>>> +            if ( emptyQuery || results.size() > 0 )
>>> +            {
>>> +                return SKIP_BODY;
>>> +            }
>>>         }
>>> -
>>> -        return SKIP_BODY;
>>> +        return EVAL_BODY_INCLUDE;
>>>     }
>>>  }
>>>
>>> Modified:
>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>> SearchResultIteratorTag.java
>>> URL:
>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultIteratorTag.java?rev=782495&r1=782494&r2=782495&view=diff
>>>
>>> = 
>>> = 
>>> = 
>>> = 
>>> = 
>>> = 
>>> = 
>>> = 
>>> = 
>>> = 
>>> ====================================================================
>>> ---
>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>> SearchResultIteratorTag.java
>>> (original)
>>> +++
>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>> SearchResultIteratorTag.java
>>> Mon Jun  8 01:37:33 2009
>>> @@ -20,12 +20,12 @@
>>>  */
>>>  package org.apache.wiki.tags;
>>>
>>> -import java.util.ArrayList;
>>>  import java.util.Collection;
>>>
>>> -import javax.servlet.jsp.PageContext;
>>> -
>>> +import org.apache.wiki.action.SearchActionBean;
>>> +import org.apache.wiki.action.WikiActionBean;
>>>  import org.apache.wiki.search.SearchResult;
>>> +import org.apache.wiki.ui.stripes.WikiInterceptor;
>>>
>>>  /**
>>>  * Iterator tag for the current search results, as identified by a
>>> @@ -36,19 +36,17 @@
>>>     private static final long serialVersionUID = 1L;
>>>
>>>     /**
>>> -     * \ Returns the list of SearchResults to iterate over.
>>> +     * Returns the list of SearchResults to iterate over.
>>>      */
>>>     @Override
>>> -    @SuppressWarnings( "unchecked" )
>>>     protected Collection<SearchResult> initItems()
>>>     {
>>> -        Collection<SearchResult> results =  
>>> (Collection<SearchResult>)
>>> pageContext.getAttribute( "searchresults",
>>> -
>>>                      PageContext.REQUEST_SCOPE );
>>> -        if( results == null )
>>> +        WikiActionBean actionBean = WikiInterceptor.findActionBean(
>>> pageContext );
>>> +        if ( actionBean != null && actionBean instanceof  
>>> SearchActionBean
>>> )
>>>         {
>>> -            return new ArrayList<SearchResult>();
>>> +            return ((SearchActionBean)actionBean).getResults();
>>>         }
>>> -        return results;
>>> +        return SearchActionBean.NO_RESULTS;
>>>     }
>>>
>>>     /**
>>>
>>> Modified:
>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>> SearchResultsSizeTag.java
>>> URL:
>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsSizeTag.java?rev=782495&r1=782494&r2=782495&view=diff
>>>
>>> = 
>>> = 
>>> = 
>>> = 
>>> = 
>>> = 
>>> = 
>>> = 
>>> = 
>>> = 
>>> ====================================================================
>>> ---
>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>> SearchResultsSizeTag.java
>>> (original)
>>> +++
>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>> SearchResultsSizeTag.java
>>> Mon Jun  8 01:37:33 2009
>>> @@ -22,8 +22,8 @@
>>>
>>>  import java.io.IOException;
>>>  import java.util.Collection;
>>> -import javax.servlet.jsp.PageContext;
>>>
>>> +import org.apache.wiki.action.SearchActionBean;
>>>  import org.apache.wiki.search.SearchResult;
>>>
>>>  /**
>>> @@ -37,17 +37,14 @@
>>>  {
>>>     private static final long serialVersionUID = 0L;
>>>
>>> -    @SuppressWarnings("unchecked")
>>>     public final int doWikiStartTag()
>>>         throws IOException
>>>     {
>>> -        Collection<SearchResult> list =
>>> (Collection<SearchResult>)pageContext.getAttribute( "searchresults",
>>> -
>>>  PageContext.REQUEST_SCOPE );
>>> -        if( list != null )
>>> +        if ( m_wikiActionBean != null && m_wikiActionBean  
>>> instanceof
>>> SearchActionBean )
>>>         {
>>> -            pageContext.getOut().print( list.size() );
>>> +            Collection<SearchResult> results =
>>> ((SearchActionBean)m_wikiActionBean).getResults();
>>> +            pageContext.getOut().print( results.size() );
>>>         }
>>> -
>>>         return SKIP_BODY;
>>>     }
>>>  }
>>>
>>> Modified:
>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>> SearchResultsTag.java
>>> URL:
>>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsTag.java?rev=782495&r1=782494&r2=782495&view=diff
>>>
>>> = 
>>> = 
>>> = 
>>> = 
>>> = 
>>> = 
>>> = 
>>> = 
>>> = 
>>> = 
>>> ====================================================================
>>> ---
>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>> SearchResultsTag.java
>>> (original)
>>> +++
>>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ 
>>> SearchResultsTag.java
>>> Mon Jun  8 01:37:33 2009
>>> @@ -21,10 +21,10 @@
>>>  package org.apache.wiki.tags;
>>>
>>>  import java.io.IOException;
>>> -import java.util.Collection;
>>> +
>>>  import javax.servlet.jsp.PageContext;
>>>
>>> -import org.apache.wiki.search.SearchResult;
>>> +import org.apache.wiki.action.SearchActionBean;
>>>
>>>  /**
>>>  *  Includes the body content, if there are any search results.
>>> @@ -36,16 +36,16 @@
>>>  {
>>>     private static final long serialVersionUID = 0L;
>>>
>>> -    @SuppressWarnings("unchecked")
>>>     public final int doWikiStartTag()
>>>         throws IOException
>>>     {
>>> -        Collection<SearchResult> list =
>>> (Collection<SearchResult>)pageContext.getAttribute( "searchresults",
>>> -
>>>  PageContext.REQUEST_SCOPE );
>>> -
>>> -        if( list != null )
>>> +        if ( m_wikiActionBean != null && m_wikiActionBean  
>>> instanceof
>>> SearchActionBean )
>>>         {
>>> -            return EVAL_BODY_INCLUDE;
>>> +            boolean emptyQuery =
>>> ((SearchActionBean)m_wikiActionBean).getQuery() == null;
>>> +            if ( !emptyQuery )
>>> +            {
>>> +                return EVAL_BODY_INCLUDE;
>>> +            }
>>>         }
>>>
>>>         String message = (String)pageContext.getAttribute( "err",
>>>
>>>
>>>
>>


Re: svn commit: r782495 - in /incubator/jspwiki/trunk/src: WebContent/ WebContent/scripts/ WebContent/templates/default/ java/org/apache/wiki/ java/org/apache/wiki/action/ java/org/apache/wiki/tags/

Posted by Andrew Jaquith <an...@gmail.com>.
It will fix this one -- but only after we've hooked it up to the
client JavaScript. Should not take long.

On Mon, Jun 8, 2009 at 2:44 PM, Harry Metske<ha...@gmail.com> wrote:
> Andrew,
>
> should this patch have fixed
> https://issues.apache.org/jira/browse/JSPWIKI-510 (only for 3.0 of course) ?
>
> Harry
>
> 2009/6/8 <aj...@apache.org>
>
>> Author: ajaquith
>> Date: Mon Jun  8 01:37:33 2009
>> New Revision: 782495
>>
>> URL: http://svn.apache.org/viewvc?rev=782495&view=rev
>> Log:
>> Search.jsp migrated to Stripes. SearchActionBean now provides searching
>> logic, including an ajaxSearch() method that filters results correctly (this
>> is not hooked up to the client JavaScript yet, but it should be
>> straightforward to do). Still some i18n cleanup to do.
>>
>> Modified:
>>    incubator/jspwiki/trunk/src/WebContent/Search.jsp
>>    incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-common.js
>>    incubator/jspwiki/trunk/src/WebContent/templates/default/FindContent.jsp
>>    incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiContext.java
>>
>>  incubator/jspwiki/trunk/src/java/org/apache/wiki/action/SearchActionBean.java
>>
>>  incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IfNoSearchResultsTag.java
>>
>>  incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultIteratorTag.java
>>
>>  incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsSizeTag.java
>>
>>  incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsTag.java
>>
>> Modified: incubator/jspwiki/trunk/src/WebContent/Search.jsp
>> URL:
>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/WebContent/Search.jsp?rev=782495&r1=782494&r2=782495&view=diff
>>
>> ==============================================================================
>> --- incubator/jspwiki/trunk/src/WebContent/Search.jsp (original)
>> +++ incubator/jspwiki/trunk/src/WebContent/Search.jsp Mon Jun  8 01:37:33
>> 2009
>> @@ -18,108 +18,12 @@
>>     specific language governing permissions and limitations
>>     under the License.
>>  --%>
>> -<%@ page import="org.apache.wiki.log.Logger" %>
>> -<%@ page import="org.apache.wiki.log.LoggerFactory" %>
>> -<%@ page import="org.apache.wiki.*" %>
>> -<%@ page import="org.apache.wiki.auth.*" %>
>> -<%@ page import="org.apache.wiki.auth.permissions.*" %>
>> -<%@ page import="java.util.*" %>
>> +<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld" prefix="s" %>
>>  <%@ page errorPage="/Error.jsp" %>
>> -<%@ page import="org.apache.wiki.search.*" %>
>> -<%@ taglib uri="http://jakarta.apache.org/jspwiki.tld" prefix="wiki" %>
>> -<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld"
>> prefix="stripes" %>
>> -<%@ page import="org.apache.wiki.util.TextUtil" %>
>> -<%@ page import="org.apache.wiki.api.WikiPage" %>
>> -<stripes:useActionBean beanclass="org.apache.wiki.action.SearchActionBean"
>> event="find" id="wikiActionBean" />
>> +<s:useActionBean beanclass="org.apache.wiki.action.SearchActionBean"
>> event="search" executeResolution="true" id="wikiActionBean" />
>> +<s:layout-render name="${templates['DefaultLayout.jsp']}">
>> +  <s:layout-component name="content">
>> +      <jsp:include page="${templates['FindContent.jsp']}" />
>> +  </s:layout-component>
>> +</s:layout-render>
>>
>> -<%!
>> -    Logger log = LoggerFactory.getLogger("JSPWikiSearch");
>> -%>
>> -
>> -<%
>> -    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
>> -    // Create wiki context and check for authorization
>> -    WikiContext wikiContext = wiki.createContext( request,
>> WikiContext.FIND );
>> -    String pagereq = wikiContext.getPage().getName();
>> -
>> -    // Get the search results
>> -    Collection list = null;
>> -    String query = request.getParameter( "query");
>> -    String go    = request.getParameter("go");
>> -
>> -    if( query != null )
>> -    {
>> -        log.info("Searching for string "+query);
>> -
>> -        try
>> -        {
>> -            list = wiki.findPages( query );
>> -
>> -            //
>> -            //  Filter down to only those that we actually have a
>> permission to view
>> -            //
>> -            AuthorizationManager mgr = wiki.getAuthorizationManager();
>> -
>> -            ArrayList filteredList = new ArrayList();
>> -
>> -            for( Iterator i = list.iterator(); i.hasNext(); )
>> -            {
>> -                SearchResult r = (SearchResult)i.next();
>> -
>> -                WikiPage p = r.getPage();
>> -
>> -                PagePermission pp = new PagePermission( p,
>> PagePermission.VIEW_ACTION );
>> -
>> -                try
>> -                {
>> -                    if( mgr.checkPermission( wikiContext.getWikiSession(),
>> pp ) )
>> -                    {
>> -                        filteredList.add( r );
>> -                    }
>> -                }
>> -                catch( Exception e ) { log.error( "Searching for page "+p,
>> e ); }
>> -            }
>> -
>> -            pageContext.setAttribute( "searchresults",
>> -                                      filteredList,
>> -                                      PageContext.REQUEST_SCOPE );
>> -        }
>> -        catch( Exception e )
>> -        {
>> -            wikiContext.getWikiSession().addMessage( e.getMessage() );
>> -        }
>> -
>> -        query = TextUtil.replaceEntities( query );
>> -
>> -        pageContext.setAttribute( "query",
>> -                                  query,
>> -                                  PageContext.REQUEST_SCOPE );
>> -
>> -        //
>> -        //  Did the user click on "go"?
>> -        //
>> -        if( go != null )
>> -        {
>> -            if( list != null && list.size() > 0 )
>> -            {
>> -                SearchResult sr = (SearchResult) list.iterator().next();
>> -
>> -                WikiPage wikiPage = sr.getPage();
>> -
>> -                String url = wikiContext.getViewURL( wikiPage.getName() );
>> -
>> -                response.sendRedirect( url );
>> -
>> -                return;
>> -            }
>> -        }
>> -    }
>> -
>> -    // Set the content type and include the response content
>> -    response.setContentType("text/html;
>> charset="+wiki.getContentEncoding() );
>> -    String contentPage = wiki.getTemplateManager().findJSP( pageContext,
>> -
>>  wikiContext.getTemplate(),
>> -
>>  "ViewTemplate.jsp" );
>> -%><wiki:Include page="<%=contentPage%>" /><%
>> -    log.debug("SEARCH COMPLETE");
>> -%>
>>
>> Modified: incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-common.js
>> URL:
>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-common.js?rev=782495&r1=782494&r2=782495&view=diff
>>
>> ==============================================================================
>> --- incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-common.js
>> (original)
>> +++ incubator/jspwiki/trunk/src/WebContent/scripts/jspwiki-common.js Mon
>> Jun  8 01:37:33 2009
>> @@ -931,9 +931,9 @@
>>                        if (option.value == match) option.selected = true;
>>                });
>>
>> -               new Ajax(Wiki.TemplateUrl+'AJAXSearch.jsp', {
>> -                       postBody: $('searchform2').toQueryString(),
>> -                       update: 'searchResult2',
>> +               new Ajax(Wiki.BasePath+'Search.action', {
>> +                       postBody:
>> "ajaxSearch=&"+$('searchform2').toQueryString(),
>> +                       update: 'searchResult2',
>>                        method: 'post',
>>                        onComplete: function() {
>>                                $('spin').hide();
>>
>> Modified:
>> incubator/jspwiki/trunk/src/WebContent/templates/default/FindContent.jsp
>> URL:
>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/WebContent/templates/default/FindContent.jsp?rev=782495&r1=782494&r2=782495&view=diff
>>
>> ==============================================================================
>> ---
>> incubator/jspwiki/trunk/src/WebContent/templates/default/FindContent.jsp
>> (original)
>> +++
>> incubator/jspwiki/trunk/src/WebContent/templates/default/FindContent.jsp Mon
>> Jun  8 01:37:33 2009
>> @@ -27,24 +27,18 @@
>>  <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
>>  <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
>>  <%@ page import="javax.servlet.jsp.jstl.fmt.*" %>
>> -<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld"
>> prefix="stripes" %>
>> +<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld" prefix="s" %>
>>
>>  <wiki:TabbedSection>
>>  <wiki:Tab id="findcontent" titleKey="find.tab" accesskey="s">
>>
>> -<form action="<wiki:Link format='url' jsp='Search.jsp'/>"
>> -       class="wikiform"
>> -          id="searchform2"
>> -         accept-charset="<wiki:ContentEncoding/>">
>> -
>> +<s:form beanclass="org.apache.wiki.action.SearchActionBean"
>> class="wikiform"
>> +    id="searchform2" acceptcharset="UTF-8">
>> +
>>   <h4><fmt:message key="find.input" /></h4>
>>   <p>
>> -    <input type="text"
>> -           name="query" id="query2"
>> -          value="<c:out value='${query}'/>"
>> -           size="32" />
>> -
>> -    <input type="checkbox" name="details" id="details" <c:if
>> test='${param.details == "on"}'>checked='checked'</c:if> />
>> +    <s:text name="query" id="query2" size="32" />
>> +    <s:checkbox name="details" id="details" />
>>     <fmt:message key="find.details" />
>>
>>     <select name="scope" id="scope">
>> @@ -55,16 +49,83 @@
>>       <option value="attachment:" <c:if test='${param.scope eq
>> "attachment:"}'>selected="selected"</c:if> ><fmt:message
>> key='find.scope.attach' /></option>
>>     </select>
>>
>> -       <input type="submit" name="ok" id="ok" value="<fmt:message
>> key="find.submit.find" />" />
>> -       <input type="submit" name="go" id="go" value="<fmt:message
>> key="find.submit.go" />" />
>> -    <input type="hidden" name="start" id="start" value="0" />
>> -    <input type="hidden" name="maxitems" id="maxitems" value="20" />
>> +    <s:submit name="search" id="ok" value="<fmt:message
>> key='find.submit.find' />" />
>> +    <s:submit name="go" id="go" value="<fmt:message key='find.submit.go'
>> />" />
>> +    <s:hidden name="start" id="start" value="0" />
>> +    <s:hidden name="maxItems" id="maxitems" value="20" />
>>
>>     <span id="spin" class="spin"
>> style="position:absolute;display:none;"></span>
>>   </p>
>> -</form>
>> +</s:form>
>> +
>> +<div id="searchResult2">
>> +  <wiki:SearchResults>
>> +
>> +    <h4><fmt:message key="find.heading.results"><fmt:param><c:out
>> value="${wikiActionBean.query}" /></fmt:param></fmt:message></h4>
>> +    <p>
>> +      <fmt:message key="find.externalsearch" />
>> +      <a class="external" href="http://www.google.com/search?q=<c:out
>> value='${wikiActionBean.query}' />" title="Google Search '<c:out
>> value='${wikiActionBean.query}' />'" target="_blank">Google</a><img
>> class="outlink" src="images/out.png" alt="" />
>> +      |
>> +      <a class="external" href="
>> http://en.wikipedia.org/wiki/Special:Search?search=<c:out
>> value='${wikiActionBean.query}' />" title="Wikipedia Search '<c:out
>> value='${wikiActionBean.query}' />'" target="_blank">Wikipedia</a><img
>> class="outlink" src="images/out.png" alt="" />
>> +    </p>
>> +
>> +    <wiki:SetPagination start="${wikiActionBean.start}"
>> total="${wikiActionBean.resultsCount}" pagesize="20" maxlinks="9"
>> fmtkey="info.pagination" onclick="$('start').value=%s;
>> SearchBox.runfullsearch();" />
>> +
>> +    <div class="graphBars">
>> +      <div class="zebra-table">
>> +        <table class="wikitable">
>> +
>> +          <tr>
>> +             <th align="left"><fmt:message key="find.results.page" /></th>
>> +             <th align="left"><fmt:message key="find.results.score"
>> /></th>
>> +          </tr>
>> +
>> +          <wiki:SearchResultIterator id="searchref"
>> start="${wikiActionBean.start}" maxItems="${wikiActionBean.maxItems}">
>> +          <tr>
>> +            <td><wiki:LinkTo><wiki:PageName/></wiki:LinkTo></td>
>> +            <td><span class="gBar"><%= searchref.getScore() %></span></td>
>> +          </tr>
>> +
>> +          <c:if test="${wikiActionBean.details == 'true'}">
>> +  <%
>> +            String[] contexts = searchref.getContexts();
>> +            if( (contexts != null) && (contexts.length > 0) )
>> +            {
>> +  %>
>> +          <tr class="odd">
>> +            <td colspan="2">
>> +              <div class="fragment">
>> +  <%
>> +              for (int i = 0; i < contexts.length; i++)
>> +              {
>> +  %>
>> +                <%= (i > 0 ) ? "<span class='fragment_ellipsis'> ...
>> </span>" : ""  %>
>> +                <%= contexts[i]  %>
>> +  <%
>> +              }
>> +  %>
>> +               </div>
>> +             </td>
>> +           </tr>
>> +  <%
>> +            }
>> +  %>
>> +          </c:if><%-- details --%>
>> +        </wiki:SearchResultIterator>
>> +
>> +        <wiki:IfNoSearchResults>
>> +          <tr>
>> +            <td class="nosearchresult" colspan="2"><fmt:message
>> key="find.noresults" /></td>
>> +          </tr>
>> +        </wiki:IfNoSearchResults>
>> +
>> +        </table>
>> +      </div>
>> +    </div>
>> +    ${pagination}
>>
>> -<div id="searchResult2"><wiki:Include page="AJAXSearch.jsp" /></div>
>> +  </wiki:SearchResults>
>> +</div>
>>
>>  </wiki:Tab>
>>
>>
>> Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiContext.java
>> URL:
>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiContext.java?rev=782495&r1=782494&r2=782495&view=diff
>>
>> ==============================================================================
>> --- incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiContext.java
>> (original)
>> +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiContext.java Mon
>> Jun  8 01:37:33 2009
>> @@ -103,7 +103,7 @@
>>     public static final String    COMMENT  = HandlerInfo.getHandlerInfo(
>> EditActionBean.class, "comment" ).getRequestContext();
>>
>>     /** User is searching for content. */
>> -    public static final String    FIND     = HandlerInfo.getHandlerInfo(
>> SearchActionBean.class, "find" ).getRequestContext();
>> +    public static final String    FIND     = HandlerInfo.getHandlerInfo(
>> SearchActionBean.class, "search" ).getRequestContext();
>>
>>     /** User wishes to create a new group */
>>     public static final String    CREATE_GROUP =
>> HandlerInfo.getHandlerInfo( GroupActionBean.class, "create"
>> ).getRequestContext();
>>
>> Modified:
>> incubator/jspwiki/trunk/src/java/org/apache/wiki/action/SearchActionBean.java
>> URL:
>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/action/SearchActionBean.java?rev=782495&r1=782494&r2=782495&view=diff
>>
>> ==============================================================================
>> ---
>> incubator/jspwiki/trunk/src/java/org/apache/wiki/action/SearchActionBean.java
>> (original)
>> +++
>> incubator/jspwiki/trunk/src/java/org/apache/wiki/action/SearchActionBean.java
>> Mon Jun  8 01:37:33 2009
>> @@ -21,18 +21,191 @@
>>
>>  package org.apache.wiki.action;
>>
>> -import org.apache.wiki.ui.stripes.WikiRequestContext;
>> +import java.util.ArrayList;
>> +import java.util.Collection;
>> +import java.util.Collections;
>> +import java.util.List;
>>
>>  import net.sourceforge.stripes.action.*;
>> +import net.sourceforge.stripes.ajax.JavaScriptResolution;
>> +
>> +import org.apache.wiki.WikiEngine;
>> +import org.apache.wiki.api.WikiPage;
>> +import org.apache.wiki.auth.AuthorizationManager;
>> +import org.apache.wiki.auth.permissions.PagePermission;
>> +import org.apache.wiki.log.Logger;
>> +import org.apache.wiki.log.LoggerFactory;
>> +import org.apache.wiki.search.SearchResult;
>> +import org.apache.wiki.ui.stripes.WikiRequestContext;
>>
>> +/**
>> + * Searches the WikiPage collection for a given wiki.
>> + */
>>  @UrlBinding( "/Search.jsp" )
>>  public class SearchActionBean extends AbstractActionBean
>>  {
>> +    private Logger log = LoggerFactory.getLogger("JSPWikiSearch");
>> +
>> +    public static final Collection<SearchResult> NO_RESULTS =
>> Collections.emptyList();
>> +
>> +    private Collection<SearchResult> m_results = NO_RESULTS;
>> +
>> +    private String m_query = null;
>> +
>> +    private int m_maxItems = 20;
>> +
>> +    private int m_start = 0;
>> +
>> +    private boolean m_details = false;
>> +
>> +    public boolean getDetails()
>> +    {
>> +        return m_details;
>> +    }
>> +
>> +    /**
>> +     * Sets the search results so that details for each result are
>> displayed.
>> +     * @param details whether details should be displayed
>> +     */
>> +    public void setDetails( boolean details )
>> +    {
>> +        m_details = details;
>> +    }
>> +
>> +    public int getMaxItems()
>> +    {
>> +        return m_maxItems;
>> +    }
>> +
>> +    public void setMaxItems( int maxItems )
>> +    {
>> +        m_maxItems = maxItems;
>> +    }
>> +
>> +    public int getStart()
>> +    {
>> +        return m_start;
>> +    }
>> +
>> +    public void setStart( int start )
>> +    {
>> +        m_start = start;
>> +    }
>> +
>> +    /**
>> +     * Returns the query string for the search.
>> +     *
>> +     * @return the query string
>> +     */
>> +    public String getQuery()
>> +    {
>> +        return m_query;
>> +    }
>> +
>> +    /**
>> +     * Returns the results of the search.
>> +     *
>> +     * @return the results
>> +     */
>> +    public Collection<SearchResult> getResults()
>> +    {
>> +        return m_results;
>> +    }
>> +
>> +    /**
>> +     * Returns the number of items returned by the current search.
>> +     * @return the number of items
>> +     */
>> +    public int getResultsCount()
>> +    {
>> +        return m_results.size();
>> +    }
>> +
>> +    /**
>> +     * Performs a search and returns the results as a list. For a given
>> WikiPage to
>> +     * be included in the results, the user must have permission to view
>> it.
>> +     * If the underlying providers encounter an abnormal IOException or
>> other error,
>> +     * it will be added to the ActionBeanContext's validation messages
>> collection.
>> +     * @param query the query
>> +     * @return the results
>> +     */
>> +    private List<SearchResult> doSearch( String query )
>> +    {
>> +        log.info("Searching with query '"+ query + "'.");
>> +        WikiEngine engine = getContext().getEngine();
>> +        AuthorizationManager mgr = engine.getAuthorizationManager();
>> +
>> +        //
>> +        //  Filter down to only those that we actually have a permission
>> to view
>> +        //
>> +        List<SearchResult> filteredResults = new
>> ArrayList<SearchResult>();
>> +        try
>> +        {
>> +            List<SearchResult> results = engine.findPages( query );
>> +            for( SearchResult result : results )
>> +            {
>> +                WikiPage page = result.getPage();
>> +                PagePermission permission = new PagePermission( page,
>> PagePermission.VIEW_ACTION );
>> +                try
>> +                {
>> +                    if( mgr.checkPermission(
>> getContext().getWikiSession(), permission ) )
>> +                    {
>> +                        filteredResults.add( result );
>> +                    }
>> +                }
>> +                catch( Exception e ) { log.error( "Searching for page " +
>> page, e ); }
>> +            }
>> +        }
>> +        catch( Exception e )
>> +        {
>> +            log.debug( "Could not search using query '" + query + "'.", e
>> );
>> +            Message message = new SimpleMessage( e.getMessage() );
>> +            getContext().getMessages().add( message );
>> +            e.printStackTrace();
>> +        }
>> +        return filteredResults;
>> +    }
>> +
>> +    /**
>> +     * Sets the query string for the search.
>> +     *
>> +     * @param query the query string
>> +     */
>> +    public void setQuery( String query )
>> +    {
>> +        m_query = query;
>> +    }
>> +
>> +    /**
>> +     * Searches the wiki using the query string set for this
>> +     * ActionBean. Search results are made available to callers via the
>> +     * {@link #getResults()} method (and EL expression
>> +     * <code>$wikiActionBean.results</code>).
>> +     *
>> +     * @return always returns a {@link ForwardResolution} to
>> +     *         <code>/Search.jsp</code>.
>> +     */
>>     @DefaultHandler
>> -    @HandlesEvent( "find" )
>> +    @HandlesEvent( "search" )
>>     @WikiRequestContext( "find" )
>> -    public Resolution view()
>> +    public Resolution search()
>>     {
>> +        m_results = m_query == null ? NO_RESULTS : doSearch( m_query );
>>         return new ForwardResolution( "/Search.jsp" );
>>     }
>> +
>> +    /**
>> +     * Using AJAX, searches a specified wiki space using the query string
>> set for this
>> +     * ActionBean. Results are streamed back to the client as an array of
>> JSON-encoded
>> +     * SearchResult objects.
>> +     *
>> +     * @return always returns a {@link JavaScriptResolution} containing
>> the
>> +     * results; this may be a zero-length array
>> +     */
>> +    @HandlesEvent( "ajaxSearch" )
>> +    public Resolution ajaxSearch()
>> +    {
>> +        m_results = m_query == null ? NO_RESULTS : doSearch( m_query );
>> +        return new JavaScriptResolution( m_results );
>> +    }
>>  }
>>
>> Modified:
>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IfNoSearchResultsTag.java
>> URL:
>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IfNoSearchResultsTag.java?rev=782495&r1=782494&r2=782495&view=diff
>>
>> ==============================================================================
>> ---
>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IfNoSearchResultsTag.java
>> (original)
>> +++
>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/IfNoSearchResultsTag.java
>> Mon Jun  8 01:37:33 2009
>> @@ -22,8 +22,8 @@
>>
>>  import java.io.IOException;
>>  import java.util.Collection;
>> -import javax.servlet.jsp.PageContext;
>>
>> +import org.apache.wiki.action.SearchActionBean;
>>  import org.apache.wiki.search.SearchResult;
>>
>>  /**
>> @@ -36,17 +36,18 @@
>>  {
>>     private static final long serialVersionUID = 0L;
>>
>> -    @SuppressWarnings("unchecked")
>>     public final int doWikiStartTag()
>>         throws IOException
>>     {
>> -        Collection<SearchResult> list =
>> (Collection<SearchResult>)pageContext.getAttribute( "searchresults",
>> -
>>  PageContext.REQUEST_SCOPE );
>> -        if( list == null || list.size() == 0 )
>> -        {
>> -            return EVAL_BODY_INCLUDE;
>> +        if ( m_wikiActionBean != null && m_wikiActionBean instanceof
>> SearchActionBean )
>> +        {
>> +            boolean emptyQuery =
>> ((SearchActionBean)m_wikiActionBean).getQuery() == null;
>> +            Collection<SearchResult> results =
>> ((SearchActionBean)m_wikiActionBean).getResults();
>> +            if ( emptyQuery || results.size() > 0 )
>> +            {
>> +                return SKIP_BODY;
>> +            }
>>         }
>> -
>> -        return SKIP_BODY;
>> +        return EVAL_BODY_INCLUDE;
>>     }
>>  }
>>
>> Modified:
>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultIteratorTag.java
>> URL:
>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultIteratorTag.java?rev=782495&r1=782494&r2=782495&view=diff
>>
>> ==============================================================================
>> ---
>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultIteratorTag.java
>> (original)
>> +++
>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultIteratorTag.java
>> Mon Jun  8 01:37:33 2009
>> @@ -20,12 +20,12 @@
>>  */
>>  package org.apache.wiki.tags;
>>
>> -import java.util.ArrayList;
>>  import java.util.Collection;
>>
>> -import javax.servlet.jsp.PageContext;
>> -
>> +import org.apache.wiki.action.SearchActionBean;
>> +import org.apache.wiki.action.WikiActionBean;
>>  import org.apache.wiki.search.SearchResult;
>> +import org.apache.wiki.ui.stripes.WikiInterceptor;
>>
>>  /**
>>  * Iterator tag for the current search results, as identified by a
>> @@ -36,19 +36,17 @@
>>     private static final long serialVersionUID = 1L;
>>
>>     /**
>> -     * \ Returns the list of SearchResults to iterate over.
>> +     * Returns the list of SearchResults to iterate over.
>>      */
>>     @Override
>> -    @SuppressWarnings( "unchecked" )
>>     protected Collection<SearchResult> initItems()
>>     {
>> -        Collection<SearchResult> results = (Collection<SearchResult>)
>> pageContext.getAttribute( "searchresults",
>> -
>>                      PageContext.REQUEST_SCOPE );
>> -        if( results == null )
>> +        WikiActionBean actionBean = WikiInterceptor.findActionBean(
>> pageContext );
>> +        if ( actionBean != null && actionBean instanceof SearchActionBean
>> )
>>         {
>> -            return new ArrayList<SearchResult>();
>> +            return ((SearchActionBean)actionBean).getResults();
>>         }
>> -        return results;
>> +        return SearchActionBean.NO_RESULTS;
>>     }
>>
>>     /**
>>
>> Modified:
>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsSizeTag.java
>> URL:
>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsSizeTag.java?rev=782495&r1=782494&r2=782495&view=diff
>>
>> ==============================================================================
>> ---
>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsSizeTag.java
>> (original)
>> +++
>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsSizeTag.java
>> Mon Jun  8 01:37:33 2009
>> @@ -22,8 +22,8 @@
>>
>>  import java.io.IOException;
>>  import java.util.Collection;
>> -import javax.servlet.jsp.PageContext;
>>
>> +import org.apache.wiki.action.SearchActionBean;
>>  import org.apache.wiki.search.SearchResult;
>>
>>  /**
>> @@ -37,17 +37,14 @@
>>  {
>>     private static final long serialVersionUID = 0L;
>>
>> -    @SuppressWarnings("unchecked")
>>     public final int doWikiStartTag()
>>         throws IOException
>>     {
>> -        Collection<SearchResult> list =
>> (Collection<SearchResult>)pageContext.getAttribute( "searchresults",
>> -
>>  PageContext.REQUEST_SCOPE );
>> -        if( list != null )
>> +        if ( m_wikiActionBean != null && m_wikiActionBean instanceof
>> SearchActionBean )
>>         {
>> -            pageContext.getOut().print( list.size() );
>> +            Collection<SearchResult> results =
>> ((SearchActionBean)m_wikiActionBean).getResults();
>> +            pageContext.getOut().print( results.size() );
>>         }
>> -
>>         return SKIP_BODY;
>>     }
>>  }
>>
>> Modified:
>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsTag.java
>> URL:
>> http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsTag.java?rev=782495&r1=782494&r2=782495&view=diff
>>
>> ==============================================================================
>> ---
>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsTag.java
>> (original)
>> +++
>> incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/SearchResultsTag.java
>> Mon Jun  8 01:37:33 2009
>> @@ -21,10 +21,10 @@
>>  package org.apache.wiki.tags;
>>
>>  import java.io.IOException;
>> -import java.util.Collection;
>> +
>>  import javax.servlet.jsp.PageContext;
>>
>> -import org.apache.wiki.search.SearchResult;
>> +import org.apache.wiki.action.SearchActionBean;
>>
>>  /**
>>  *  Includes the body content, if there are any search results.
>> @@ -36,16 +36,16 @@
>>  {
>>     private static final long serialVersionUID = 0L;
>>
>> -    @SuppressWarnings("unchecked")
>>     public final int doWikiStartTag()
>>         throws IOException
>>     {
>> -        Collection<SearchResult> list =
>> (Collection<SearchResult>)pageContext.getAttribute( "searchresults",
>> -
>>  PageContext.REQUEST_SCOPE );
>> -
>> -        if( list != null )
>> +        if ( m_wikiActionBean != null && m_wikiActionBean instanceof
>> SearchActionBean )
>>         {
>> -            return EVAL_BODY_INCLUDE;
>> +            boolean emptyQuery =
>> ((SearchActionBean)m_wikiActionBean).getQuery() == null;
>> +            if ( !emptyQuery )
>> +            {
>> +                return EVAL_BODY_INCLUDE;
>> +            }
>>         }
>>
>>         String message = (String)pageContext.getAttribute( "err",
>>
>>
>>
>