For most query types, ATG Search returns the query results as an object of class com.primus.searchstudio.Results
. Each form handler has a results
property for storing a Results
object, so you can display the query results in a JSP. For example, the following JSP fragment creates a three-column table that displays the label, path, and score properties of each category in the Results.suggestedCategories
List property:
<dspel:getvalueof bean="${formHandlerPath}.results" var="results"/> <c:set value="${results}" var="results" scope="request"/> <table border="1" width="100%"> <tr bgcolor="LIGHTBLUE"> <td>label</td> <td>path</td> <td>score</td> </tr> <c:if test="${ ! empty results.suggestedCategories }"> <c:forEach items="${results.suggestedCategories}" var="category"> <tr> <td> <c:out value="${category.label}"/> </td> <td> <c:out value="${category.path}"/> </td> <td> <c:out value="${category.score}"/> </td> </tr> </c:forEach> </c:if> </table>
Notice that most of the JSP tags in this example are standard JSTL tags, rather than DSP tags, because the Results
object is not a Nucleus component.
For the <browse>
query type, ATG Search returns the query results as an array of objects of class com.primus.searchstudio.CategoryDocument
. These objects are stored in the results.categories.combinedResults.categoryDocuments
array of the BrowseFormHandler
. To display results from a <browse>
query, you retrieve them from this array. For example, the following JSP fragment creates a table in which each row displays the properties of a different CategoryDocument
object:
<table border="1" width="100%"> <tr bgcolor="LIGHTBLUE"> <td>timestamp</td> <td>paTimestamp</td> <td>popularity</td> <td>vicDocTypeAsString</td> <td>title</td> <td>fullTitle</td> <td>isTruncated</td> <td>FAQ</td> <td>responseId</td> <td>normalizedResponse</td> <td>properties</td> </tr> <c:if test="${ ! empty results.categories }"> <c:forEach items="${results.categories.combinedResults.categoryDocuments}" var="document"> <tr> <td> <c:out value="${document.timestamp}"/> </td> <td> <c:out value="${document.paTimestampString}"/> </td> <td> <c:out value="${document.popularity}"/> </td> <td> <c:out value="${document.vicDocTypeAsString}"/> </td> <td> <c:out value="${document.title}"/> </td> <td> <c:out value="${document.fullTitle}"/> </td> <td> <c:out value="${document.isTruncated}"/> </td> <td> <c:out value="${document.faq}"/> </td> <td> <c:out value="${document.responseId}"/> </td> <td> <c:out value="${document.normalizedResponse}"/> </td> <td> <table border="1"> <tr bgcolor="LIGHTBLUE"> <td>key</td> <td>value</td> </tr> <c:forEach items="${document.properties}" var="property"> <tr> <td> <c:out value="${property.key}"/> </td> <td> <c:out value="${property.value}"/> </td> </tr> </c:forEach> </table> </td> </tr> </c:forEach> </c:if> </table>