mirror of https://github.com/apache/archiva.git
fix display of search results with pagination
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1179993 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
47229dec13
commit
649e73136c
|
@ -462,6 +462,7 @@ public class NexusRepositorySearch
|
|||
}
|
||||
|
||||
results.setTotalHits(response.getTotalHitsCount());
|
||||
results.setTotalHitsMapSize(results.getHitsMap().values().size());
|
||||
results.setReturnedHitsCount(response.getReturnedHitsCount());
|
||||
results.setLimits(limits);
|
||||
|
||||
|
@ -631,6 +632,7 @@ public class NexusRepositorySearch
|
|||
}
|
||||
paginated.setTotalHits(results.getTotalHits());
|
||||
paginated.setReturnedHitsCount(paginated.getHits().size());
|
||||
paginated.setTotalHitsMapSize( results.getTotalHitsMapSize() );
|
||||
paginated.setLimits(limits);
|
||||
|
||||
return paginated;
|
||||
|
|
|
@ -36,6 +36,8 @@ public class SearchResults
|
|||
|
||||
private int totalHits;
|
||||
|
||||
private int totalHitsMapSize;
|
||||
|
||||
private int returnedHitsCount;
|
||||
|
||||
private SearchResultLimits limits;
|
||||
|
@ -120,6 +122,24 @@ public class SearchResults
|
|||
this.returnedHitsCount = returnedHitsCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.4-M1
|
||||
* @return
|
||||
*/
|
||||
public int getTotalHitsMapSize()
|
||||
{
|
||||
return totalHitsMapSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.4-M1
|
||||
* @param totalHitsMapSize
|
||||
*/
|
||||
public void setTotalHitsMapSize(int totalHitsMapSize)
|
||||
{
|
||||
this.totalHitsMapSize = totalHitsMapSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
|
|
|
@ -347,8 +347,7 @@ public class SearchAction
|
|||
{
|
||||
if ( searchResultsOnly && !completeQueryString.equals("") )
|
||||
{
|
||||
results =
|
||||
getNexusSearch( ).search( getPrincipal( ), selectedRepos, q, limits, parseCompleteQueryString( ) );
|
||||
results = getNexusSearch().search(getPrincipal(), selectedRepos, q, limits, parseCompleteQueryString());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -368,9 +367,9 @@ public class SearchAction
|
|||
return INPUT;
|
||||
}
|
||||
|
||||
totalPages = results.getTotalHits( ) / limits.getPageSize( );
|
||||
totalPages = results.getTotalHitsMapSize() / limits.getPageSize();
|
||||
|
||||
if ( ( results.getTotalHits( ) % limits.getPageSize( ) ) != 0 )
|
||||
if ( ( results.getTotalHitsMapSize() % limits.getPageSize() ) != 0 )
|
||||
{
|
||||
totalPages = totalPages + 1;
|
||||
}
|
||||
|
@ -624,8 +623,8 @@ public class SearchAction
|
|||
{
|
||||
if ( nexusSearch == null )
|
||||
{
|
||||
WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(
|
||||
ServletActionContext.getServletContext( ) );
|
||||
WebApplicationContext wac =
|
||||
WebApplicationContextUtils.getRequiredWebApplicationContext(ServletActionContext.getServletContext());
|
||||
nexusSearch = wac.getBean("nexusSearch", RepositorySearch.class);
|
||||
}
|
||||
return nexusSearch;
|
||||
|
|
|
@ -136,10 +136,10 @@
|
|||
<c:when test="${results.totalHits > results.limits.pageSize}">
|
||||
<c:choose>
|
||||
<c:when test="${fn:length(results.hits) < rowCount}">
|
||||
<p>Hits: ${(rowCount * currentPage) + 1} to ${hitsNum} of ${results.totalHits}</p>
|
||||
<p>Hits: ${(rowCount * currentPage) + 1} to ${hitsNum} of ${results.totalHitsMapSize}</p>
|
||||
</c:when>
|
||||
<c:otherwise>
|
||||
<p>Hits: ${(hitsNum - results.limits.pageSize) + 1} to ${hitsNum} of ${results.totalHits}</p>
|
||||
<p>Hits: ${(hitsNum - results.limits.pageSize) + 1} to ${hitsNum} of ${results.totalHitsMapSize}</p>
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
</c:when>
|
||||
|
|
Loading…
Reference in New Issue