Yahoo search taglib ver. 1.2

    Custom JSP taglib lets you deploy Yahoo search API right in your JSP pages. Tags are using Yahoo's API for search and let you provide a customized output. For example the following code performs a search for Coldtags suite via Yahoo.
 



<%@ taglib uri="taglib.tld" prefix="y" %>

<y:YahooSearch query="Coldtags suite" appid="your_Yahoo_ID" result="A"/>

By default tag uses a web search from Yahoo (http://api.search.yahoo.com/WebSearchService/V1/webSearch). You can use also the following URL's:
image search - http://api.search.yahoo.com/ImageSearchService/V1/imageSearch,
local search - http://api.local.yahoo.com/LocalSearchService/V1/localSearch,
news search - http://api.search.yahoo.com/NewsSearchService/V1/newsSearch,
video search - http://api.search.yahoo.com/VideoSearchService/V1/videoSearch.

Tag YahooSearch creates a page scope variable with results. And now you can examine your results:
 



Total available: <y:getTotalResultsAvailable result="A"/>
<y:ForEachResult result="A" id="item">
<p>url=<%=item.getUrl()%>
<%=var.getTitle()%>
</y:ForEachResult>

Tag ForEachResult iterates over returned records. The nested page scope variable described by the attribute id lets you request the following properties:

getTitle() - title
getSummary() - returns a summary;
getUrl() - returns an URL;
getClickUrl() - return a click URL;
getModificationDate() - returns a date;
getMimeType() - returns a mime type;
getCacheUrl() - returns a cache URL;
getCacheSize() - returns a size;

Tags are:

YahooSearch

Body tag lets you perform a search via Yahoo API. Parameters are:

1) appid Optional parameter. Describes your application id from Yahoo.
2) urlOptional parameter. Describes an URL that will be used for the search request. By default it is http://api.search.yahoo.com/WebSearchService/V1/webSearch (web search from Yahoo).
3) query Describes your query for the search.
4) count Optional parameter. Describes how many results the search engine will return. Default value is 10.
5) start Optional parameter. Describes an initial position for the returned data. Default value is 1.
6) result Describes a name for your page scope variable that will keep the results.
7) proxyHost Optional parameter. Describes a proxy setting for HTTP requests.
8) proxyPort Optional parameter. Describes a proxy setting for HTTP requests.

ForEachResult

Body tag lets you iterate over returned data. Parameters are:

1) result Describes a name for your page scope variable that keeps the results.
2) id Describes a name for your page scope variable that will keep a reference to the current record.

getTotalResultsAvailable

Returns total available results. Parameters are:

1) result Describes a name for your page scope variable that keeps the results.
2) id Optional parameter. Describes a name for your page scope variable (type is java.lang.Integer) that will keep a counter. Without this attribute tags simply prints data.

getTotalResultsReturned

Prints returned results. Parameters are:

1) result Describes a name for your page scope variable that keeps the results.
2) id Optional parameter. Describes a name for your page scope variable (type is java.lang.Integer) that will keep a counter. Without this attribute tags simply prints data.

getFirstResultPosition

Prints a first position. Parameters are:

1) result Describes a name for your page scope variable that keeps the results.
2) id Optional parameter. Describes a name for your page scope variable (type is java.lang.Integer) that will keep a value. Without this attribute tags simply prints data.
 

for downloading:

 Library: yahoosearchtag.jar     Description: taglib.tld  

 © Coldbeans      Comments?

See also Coldtags suite - the largest collection of custom JSP tags.

Also in Coldtags: