Tutorial: Customizing Web services and WebSphere Portal to support a new search > < Previous | Next >

 

Change SearchDisplay.jsp to use the new search expression

This section refers to changing SearchDisplay.jsp to use the new search expression.On the project explorer view of WebSphere Portal development environment.

  1. Navigate to MVCPortlet > WebContent >jsp > html > catalog in Rational Application Developer.

  2. Open SearchDisplay.jsp under catalog folder.

  3. Find the lines of code
    <portlet:renderURL var="CategoryDisplayURL">
            <portlet:param name="renderName" value="CategoryDisplay"
    />
            <portlet:param name="catGroupId"
    value="${param.catGroupId}" />
    </portlet:renderURL>
    
    Add the code below after the line </portlet:renderURL>:
    <portlet:renderURL var="PriceSearchDisplayURL">
            <portlet:param name="renderName" value="SearchDisplay"
    />
            <portlet:param name="criteria" value="${param.criteria}"
    />
            <portlet:param name="minPrice" value="${param.minPrice}"
    />
            <portlet:param name="maxPrice" value="${param.maxPrice}"
    />
    </portlet:renderURL>
    

  4. Find the following lines of code
    <wcf:getData
           
    type="com.ibm.commerce.catalog.facade.datatypes.CatalogEntryType[]"
            var="products"
    expressionBuilder="findCatalogEntriesDetailsByName"
            varShowVerb="showProducts" maxItems="${pageSize}"
            recordSetStartNumber="${(currentPage - 1) * pageSize}">
            <wcf:param name="name" value="${param.criteria}" />
            <wcf:param name="nameOp" value="LIKE" />
            <wcf:param name="searchTermScope" value="1" />
            <wcf:param name="recordSetStartNumber"
                            value="${(currentPage - 1) * pageSize}"
    />
            <wcf:param name="maxItems" value="${pageSize}" />
    </wcf:getData>
    
    Replace this code with the following code:
    <c:choose>
          <%-- If minPrice and maxPrice textfields are empty, just
    search by name --%>
          <c:when test="${empty param.minPrice && empty
    param.maxPrice}">
            <wcf:getData
                   
    type="com.ibm.commerce.catalog.facade.datatypes.CatalogEntryType[]"
                    var="products"
    expressionBuilder="findCatalogEntriesDetailsByName"
                    varShowVerb="showProducts" maxItems="${pageSize}"
                    recordSetStartNumber="${(currentPage - 1) *
    pageSize}">
                    <wcf:param name="name" value="${param.criteria}"
    />
                    <wcf:param name="nameOp" value="LIKE" />
                    <wcf:param name="searchTermScope" value="1"
    />
                    <wcf:param name="recordSetStartNumber"
                            value="${(currentPage - 1) * pageSize}"
    />
                    <wcf:param name="maxItems" value="${pageSize}"
    />
            </wcf:getData>    
          </c:when>
          <c:otherwise>
            <wcf:getData
                   
    type="com.ibm.commerce.catalog.facade.datatypes.CatalogEntryType[]"
             var="products"
    expressionBuilder="findCatalogEntriesDetailsByPriceRange"
                    varShowVerb="showProducts" maxItems="${pageSize}"
                    recordSetStartNumber="${(currentPage - 1) *
    pageSize}">
                    <wcf:param name="name" value="${param.criteria}"
    />
                    <wcf:param name="minPrice"
    value="${param.minPrice}" />
                    <wcf:param name="maxPrice"
    value="${param.maxPrice}" />        
                    <wcf:param name="recordSetStartNumber"
                            value="${(currentPage - 1) * pageSize}"
    />
                    <wcf:param name="maxItems" value="${pageSize}"
    />
           </wcf:getData>    
          </c:otherwise>
      </c:choose>
    

  5. Find the following lines of code
    <portlet:renderURL var="SearchDisplayJumpURL">
            <portlet:param name="renderName" value="SearchDisplay"
    />
            <portlet:param name="criteria" value="${param.criteria}"
    />   
    </portlet:renderURL>
    
    Replace this code with the following code:
    <portlet:renderURL var="SearchDisplayJumpURL">
            <portlet:param name="renderName" value="SearchDisplay"
    />
            <portlet:param name="criteria" value="${param.criteria}"
    />                           
            <portlet:param name="minPrice" value="${param.minPrice}"
    />
            <portlet:param name="maxPrice" value="${param.maxPrice}"
    />
    </portlet:renderURL>
    

  6. Find the following lines of code
    <portlet:renderURL var="SearchDisplayFirstURL">
            <portlet:param name="renderName" value="SearchDisplay"
    />
            <portlet:param name="criteria" value="${param.criteria}"
    />                                                           
            <portlet:param name="currentPage" value="1" />
    </portlet:renderURL>
    
    Replace this code with the following code:
    <portlet:renderURL var="SearchDisplayFirstURL">
            <portlet:param name="renderName" value="SearchDisplay"
    />
            <portlet:param name="criteria" value="${param.criteria}"
    />                                                           
            <portlet:param name="minPrice" value="${param.minPrice}"
    />
            <portlet:param name="maxPrice" value="${param.maxPrice}"
    />
            <portlet:param name="currentPage" value="1" />
    </portlet:renderURL>
    

  7. Find the lines of code
    <portlet:renderURL var="SearchDisplayPreviousURL">
            <portlet:param name="renderName" value="SearchDisplay"
    />
            <portlet:param name="criteria" value="${param.criteria}"
    />                                   
            <portlet:param name="currentPage"
    value="${currentPage-1}" />
    </portlet:renderURL>
    
    Replace this part of code with the code below:
    <portlet:renderURL var="SearchDisplayPreviousURL">
            <portlet:param name="renderName" value="SearchDisplay"
    />
            <portlet:param name="criteria" value="${param.criteria}"
    />                                                           
            <portlet:param name="minPrice" value="${param.minPrice}"
    />
            <portlet:param name="maxPrice" value="${param.maxPrice}"
    />
            <portlet:param name="currentPage"
    value="${currentPage-1}" />
    </portlet:renderURL>
    

  8. Find the lines of code
    <portlet:renderURL var="SearchDisplayNextURL">
            <portlet:param name="renderName" value="SearchDisplay"
    />
            <portlet:param name="criteria" value="${param.criteria}"
    />                                           
            <c:choose>
                    <c:when test="${currentPage <
    totalPages}">
                            <portlet:param name="currentPage"
    value="${currentPage+1}" />
                    </c:when>
                    <c:otherwise>
                            <portlet:param name="currentPage"
    value="${totalPages}" />
                    </c:otherwise> 
            </c:choose>
    </portlet:renderURL>
    
    Replace this part of code with the code below:
    <portlet:renderURL var="SearchDisplayNextURL">
            <portlet:param name="renderName" value="SearchDisplay"
    />
            <portlet:param name="criteria" value="${param.criteria}"
    />                                                           
            <portlet:param name="minPrice" value="${param.minPrice}"
    />
            <portlet:param name="maxPrice" value="${param.maxPrice}"
    />
            <c:choose>
                    <c:when test="${currentPage <
    totalPages}">
                            <portlet:param name="currentPage"
    value="${currentPage+1}" />
                    </c:when>
                    <c:otherwise>
                            <portlet:param name="currentPage"
    value="${totalPages}" />
                    </c:otherwise> 
            </c:choose>
    </portlet:renderURL>
    

  9. Find the lines of code
    <portlet:renderURL var="SearchDisplayLastURL">
            <portlet:param name="renderName" value="SearchDisplay"
    />
            <portlet:param name="criteria" value="${param.criteria}"
    />                                                   
            <portlet:param name="currentPage" value="${totalPages}"
    />
    </portlet:renderURL>
    
    Replace this part of code with the code below:
    <portlet:renderURL var="SearchDisplayLastURL">
            <portlet:param name="renderName" value="SearchDisplay"
    />
            <portlet:param name="criteria" value="${param.criteria}"
    />                                                           
            <portlet:param name="minPrice" value="${param.minPrice}"
    />
            <portlet:param name="maxPrice" value="${param.maxPrice}"
    />
            <portlet:param name="currentPage" value="${totalPages}"
    />
    </portlet:renderURL>
    

  10. Find the lines of code
    <td><a
    href="javascript:document.<portlet:namespace/>SearchJumpForm.submit();"><img
                    src="<wcp:encodeURL
    url="images/ps_page_jump.gif" remote="false" escapeStore="true"
    />"
                    width="16" height="16"
    border="0"></a></td>
    
    Insert the line below after </td>:
     <%@ include file="../TutorialPriceSearch/PriceSearch.jsp"%> 
    

  11. Find the lines of code
    <c:when test="${product.catalogEntryTypeCode eq
    'ProductBean'}">
            <c:set var="draggable" value="false" />
    </c:when>
    
    Replace this part of code with the code below:
    <c:when test="${product.catalogEntryTypeCode eq
    'ProductBean'}">
            <c:set var="draggable" value="true" />
    </c:when>
    

  12. Save and close the file.

< Previous | Next >