Sun Java System Portal Server 7 Developer Sample Guide

Customizing the Search Provider

This section describes how to perform some common customizations on the Search provider.

ProcedureTo Add last-modified to the Search Result Display

Steps
  1. Modify searchOnly.jsp file by adding last-modified to the list of viewAttributes.

    For example:


    <search:setViewAttributes viewAttributes="hl-url,hl-title,hl-description,score,content-length,hl-classification,last-modified"/>
  2. Modify results.jsp file to display the last-modified date for document results using the SOIF getValue tag.

    For example:


    <% if (formbean.getDescription().equals("full")) { %>
        <FONT color=<%=tFontColor%> face=<%=tFontFace%>><search:getValue soifAttribute="description" escape="false"/></FONT><BR>
        <FONT color=#707070 face=<%=tFontFace%>><search:getURL escape="true"/><BR>
        <search:getValue soifAttribute="content-length" id="sz"/>
        <search:getValue soifAttribute="last-modified"/><BR>
    <% } %>
  3. Run the touch command.

    For example, type touch *.jsp.

  4. Reload the Desktop to verify the change.

ProcedureTo Remove content-length from Search Results

Steps
  1. (Optional) Modify searchOnly.jsp file by removing content-length from the list of viewAttributes.

    The line to modify is the following:


    <search:setViewAttributes viewAttributes="hl-url,hl-title,hl-description,score,content-length,classification hl-classification"/>

    Remove content-length from this line.

  2. Modify results.jsp file by removing the line that displays the content-length.

    The line to modify is the following:


    <% } else if (formbean.getDescription().equals("full")) { %>
        <FONT size=-1 color=<%=tFontColor%> face=<%=tFontFace%>><search:getValue soifAttribute="hl-description" escape="false"/></FONT><BR>
        <FONT size=-1 color=#707070 face=<%=tFontFace%>><search:getValue soifAttribute="hl-url" escape="false"/><BR>
        <search:getValue soifAttribute="content-length" id="sz"/>
  3. Remove <search:getValue soifAttribute="content-length" id="sz"/> from this file.

  4. Run the touch command.

    For example, type touch *.jsp.

  5. Reload the Desktop to verify the change.

ProcedureTo Display the Total Number of Documents in the Search Result Status Message

In this procedures, Steps 1 and 2 are independent of each other. If desired, run the touch command after Step 1 to see the results.

Steps
  1. Modify results.jsp by changing the search status line to add the <search:getTotalDocuments/> tag.

    For example:


    <NOBR><B>Document matches <search:getFirstHit/> - <search:getToHit/> (of <search:getHitCount/>)</B> out of <search:getTotalDocuments/></NOBR><BR>

    This results in the following display:


    Document matches 1 - 6 (of 6) out of 37
  2. Change browseResults.jsp by adding the <search:getTotalDocuments/> tag to the search status.

    For example:


    <FONT color="<%=tFontColor%>" face="<%=tFontFace%>" size="-1"><b>Subcategories <search:getFirstHit/> - <search:getToHit/> (of <search:getHitCount/>)</B> out of <search:getTotalDocuments/></FONT><br>

    This results in the following display:


    Category matches 1 - 2 (of 2) out of 86
  3. Run the touch command.

    For example, type touch *.jsp.

  4. Reload the Desktop to verify the change.

ProcedureTo Remove author from the Advanced Search Interface

Steps
  1. Comment out or remove the author related HTML from the advancedSearch.jsp file.

    For example:


    <!--     -->
    <!-- To disclude the "author" row, remark out the following section -->
    <!--     -->
    <TR>
        <td valign=middle align=right height=40><FONT color=<%=tFontColor%> face=<%=tFontFace%>><nobr> <LABEL FOR="advAuthor">Author</LABEL>
        <SELECT NAME="authorOp">
        <OPTION VALUE=<%=SearchContext.CONTAIN%> <%=formbean.authorOpSelection(SearchContext.CONTAIN)%>>does</OPTION>
        <OPTION VALUE=<%=SearchContext.NOTCONTAIN%> <%=formbean.authorOpSelection(SearchContext.NOTCONTAIN)%>>does not</OPTION>
        </SELECT>contain&nbsp;</FONT></nobr></TD>
        <td valign=middle align=left height=40><INPUT TYPE="text" NAME="authorVal" id="advAuthor" VALUE= "<%=SearchContext.htmlEncode(formbean.getAuthorVal())%>"></TD>
    </TR>
  2. Comment out author- related lines in advQuery.jsp file.


    // h = new HashMap();
        // h.put(SearchContext.OPERAND, "author");
        // h.put(SearchContext.OPERATION, formbean.getAuthorOp());
        // h.put(SearchContext.VALUE, formbean.getAuthorVal());
        // l.add(h);
    
        h = new HashMap();
        h.put(SearchContext.OPERAND, "title");
  3. Run the touch command.

    For example, type touch *.jsp.

  4. Reload the Desktop to verify the change.

ProcedureTo Add a New Field to Advanced Search

Steps
  1. Uncomment the keywords section in advancedSearch.jsp file.


    <!--     -->
    <!-- To Include the "Keywords" row, unremark the following section -->
    <!--
    <TR>
    <td valign=middle align=right height=40><FONT color=<%=tFontColor%> face=<%=tFontFace%>><nobr> <LABEL FOR="advKeywords">Keywords</LABEL>
    <SELECT NAME="keywordsOp">
    <OPTION VALUE=<%=SearchContext.CONTAIN%> <%=formbean.keywordsOpSelection(SearchContext.CONTAIN)%>>does</OPTION>
    <OPTION VALUE=<%=SearchContext.NOTCONTAIN%> <%=formbean.keywordsOpSelection(SearchContext.NOTCONTAIN)%>>does not</OPTION>
    </SELECT>contain&nbsp;</FONT></nobr></TD>
    <td valign=middle align=left height=40><INPUT TYPE="text" NAME="keywordsVal" id="advKeywords" VALUE= "<%=SearchContext.htmlEncode(formbean.getKeywordsVal())%>"></TD>
    </TR>
    -->

    Remove the <!-- and --> comment marks from this section.

  2. Add the keywords to advQuery.jsp file.


    h = new HashMap();
    h.put(SearchContext.OPERAND, "keywords");
    h.put(SearchContext.OPERATION, formbean.getKeywordsOp());
    h.put(SearchContext.VALUE, formbean.getKeywordsVal());
    l.add(h);
  3. Run the touch command.

    For example, type touch *.jsp.

  4. Reload the Desktop to verify the change.