Tutorials > Program model > Web services > Customize Web services and WebSphere Portal to support a new search
Change SearchDisplay.jsp to use the new search expression
- In the Enterprise Explorer view of Rational Application Developer, edit...
MVCPortlet > WebContent >jsp > html > catalog > SearchDisplay.jsp
- Find the following code snippet:
<portlet:renderURL var="CategoryDisplayURL"> <portlet:param name="renderName" value="CategoryDisplay" /> <portlet:param name="catGroupId" value="${param.catGroupId}" /> </portlet:renderURL>
Insert the following code after the snippet:
<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>
- Find the following code snippet:
<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 it 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>
- Find the following code snippet:
<portlet:renderURL var="SearchDisplayJumpURL"> <portlet:param name="renderName" value="SearchDisplay" /> <portlet:param name="criteria" value="${param.criteria}" /> </portlet:renderURL>
Replace it 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>
- Find the following code snippet:
<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 it 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>
- Find the following code snippet:
<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 it with the following code:
<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>
- Find the following code snippet:
<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 it with the following code:
<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>
- Find the following code snippet:
<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 it with the following code:
<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>
- Find the following code snippet:
<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 following code after the snippet:
<%@ include file="../TutorialPriceSearch/PriceSearch.jsp"%>
- Find the following code snippet:
<c:when test="${product.catalogEntryTypeCode eq 'ProductBean'}"> <c:set var="draggable" value="false" /> </c:when>
Replace it with the code below:
<c:when test="${product.catalogEntryTypeCode eq 'ProductBean'}"> <c:set var="draggable" value="true" /> </c:when>
- Save and close the file.