Sun Java System Portal Server 7.1 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

  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

  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.

    Comment the lines as shown here:


    <%--
    	<search:getValue attribute="content-length" id="sz"/>
    	<jx:declare id="sz" type="java.lang.String"/>
    	<%
    		int sizek = 1;
    		try {
    			sizek = Math.max(1, (Integer.parseInt(sz) + 512)/1024 );
    		} catch (Exception e) {
    		}
    	%>
    	<i18n:message key="size" bundle="searchjsp"/>
    	<%= sizek %>k&nbsp;
    --%>"
  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

  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.


    if (!formbean.getAuthorVal().equals("")) {
        h = new HashMap();
        h.put(SearchContext.OPERAND, "author");
        h.put(SearchContext.OPERATION, formbean.getAuthorOp());
        h.put(SearchContext.VALUE, formbean.getAuthorVal());
        l.add(h);
    }
  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

  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.


    if (!formbean.getKeywordsVal().equals("")) {
      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.