Sun Java System Web Server 7.0 Update 4 Developer's Guide to Java Web Applications

JSP Search Tags

Web Server includes a set of JSP tags that can be used to customize the search query and search results pages in the search interface. This section describes the tags and how they are used.

The search tag library is packaged into the install_dir/lib/webserv-rt.jar file, which is always on the server classpath. The sun-web-search.tld tag description file can be found in the install_dir/lib/tlds directory, you can copy this file into the WEB-INF directory of your web application.

The search tags are as follows:


Note –

The Web Server search feature is compliant for internalization, and supports multiple character encoding schemes in the same collection. Custom JSPs that expose search can be in any encoding.


searchForm Tag

This tag constructs an HTML form that contains default, hidden form elements such as the current search result index and number of records per page by default. The default names for the form, index, and number of records are searchform, si, and ns.

Attributes

The searchForm tag uses the following attributes:

Usage

<s1ws:form action="results.jsp" />
...
</s1ws:searchForm>

This example creates an HTML form tag <form name="searchform" action="results.jsp" method="GET">, along with two hidden input boxes:

CollElem Tag

This tag creates a hidden inputbox or select box, or multiple checkboxes, depending on the attribute input. If only one collection exists, the tag will create a hidden inputbox by default.

Attributes

The CollElem tag uses the following attributes:

Usage

<s1ws:collElem type="checkbox" cols="2" values="1,0,1,0" cssClass="body" />

This example creates checkboxes in 2 columns with a default name c with the first and third items selected. Fonts and any other HTML styles are defined in the css class body, which includes tr.body, td.body, and input.body.

collection Tag

This tag retrieves the name of the search collections on the server, iterates through them , and passes each of them to the collectionitem tag. Use this tag with collection item tags write your own HTML search collections.

Attributes

Optional - A comma-delimited string representing the search collections available. The tag retrieves all collections available on the server if the attribute is empty.

Usage

<table border=0>
				<s1ws:collection>
		    	<tr><td><input type=checkbox name="c" 
        value="<s1ws:collItem property="name" />">
        <s1ws:collItem property="display name" /
				></td></tr>
			</s1ws:collection>
</table>

The above code will display all collections with checkboxes.

<select name=elementname>
<s1ws:collection>
<option value="<s1ws:collItem property="name" />">
<s1ws:colleItem property="display name" />
</s1ws:collection>
</select>

This function iterates through the available collections and passes each item to the collection item tag, which in turn displays the name and display name of the item.

colIItem Tag

This tag displays the name and label of one collection item. This tag must be used inside the collection tag.

Attributes

Property - Specifies a keyword indicating which property the tag should output. Valid inputs include name, display name, and description. Default is name.

Usage

<select name=elementname>
			<s1ws:collection>
			<option value="<s1ws:collItem property="name" />">
       <s1ws:collItem property="display name" />
			</s1ws:collection>
</select>

This function iterates through the available collections and passes each item to the collection item tag, which in turn displays the name and display name of the item.

queryBox Tag

This tag creates an input box.

Attributes

The queryBox tag uses the following attributes:

Usage

<s1ws:queryBox size="30"/>

This example creates an inputbox with default name qt and size=30.

submitButton Tag

This tag creates a submit button.

Attributes

The submitButton tag uses the following attributes:

Usage

<s1ws:submitButton cssClass="navBar" style="padding: 0px; margin: 0px; width: 50px">

This example creates a submit button with default name sb.

formAction Tag

This tag performs the following sections:

Attributes

The formAction tag uses the following attributes:

Usage

<s1ws:formAction />

formSubmission Tag

This tag tests whether the form submission is successful.

Attributes

The formsubmission tag uses the following attributes:

Usage

<s1ws:formSubmission success="true" >
         <s1ws:search>
         ...
   </s1ws:formSubmission>

formActionMsg Tag

This tag prints out an error message from formAction, if any.

Attributes

The formActionMsg tag uses the following attributes:

Usage

<FormActionMsg elem="query">

This tag displays the message query text not specified if a query is not submitted.

The message is printed from the form action where the tag is placed.

search Tag

This tag executes a search query and returns search results. The search tag retrieves a query string and collections from either a form parent tag or the query and collection attributes. The search results are saved in the page context with a page or session scope.

Attributes

The search tag uses the following attributes:

Usage

<s1ws:search />

This search tag uses the default parameters and executes a search. The search results are saved in pageContext with a page scope.

<s1ws:search Collection="col1, col2" Query="Java Web Service" scope="2" />

This search tag executes a search in col1 and col2 using "Java Web Service" as the query string. The search results are saved in pageContext with a session scope.

resultIteration Tag

This tag retrieves the search results from either the parent search tag or the page context. The tag iterates through the results and passing the searchitems to the item tags.

Attributes

The resultIteration tag uses the following attributes:

Item Tag

This tag retrieves a searchitem from the Results parent tag and outputs its properties as specified by the property attribute.

Attributes

Property. Specifies a case-sensitive string representing field names in a search item, such as title, number, score, filename, URL, size, and date.

resultStat Tag

This tag returns numbers indicating number of records returned and the range currently displayed.

Attributes

The resultStat tag uses the following attributes:

resultNav Tag

This tag creates a navigation bar.

Attributes

The resultNav tag uses the following attributes: