The Artima Developer Community
Sponsored Link

Java Buzz Forum
Installing the Ajax Search API on this blog

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
dion

Posts: 5028
Nickname: dion
Registered: Feb, 2003

Dion Almaer is the Editor-in-Chief for TheServerSide.com, and is an enterprise Java evangelist
Installing the Ajax Search API on this blog Posted: Feb 6, 2007 9:00 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by dion.
Original Post: Installing the Ajax Search API on this blog
Feed Title: techno.blog(Dion)
Feed URL: http://feeds.feedburner.com/dion
Feed Description: blogging about life the universe and everything tech
Latest Java Buzz Posts
Latest Java Buzz Posts by dion
Latest Posts From techno.blog(Dion)

Advertisement

I am having fun playing with the various Google APIs, and just added the Ajax Search API to this blog.

This allowed me to get rid of the poor search that was in the blog software itself, and just let Google to the work.

The search happens inline, with results showing up on the left hand bar itself. I could have used a different model to put the results in a div on the right hand side, which is many cases is probably better.

I used the tabbed search control that enables results to be shown for the web in general, and across blogs, as well as the default... pinned to this site.

The bulk of the work is this JavaScript function, that shows the API at work:

    function OnLoad() {
      // Create a search control
      var searchControl = new GSearchControl();

// Setup a search for this site
var siteSearch = new GwebSearch();
siteSearch.setUserDefinedLabel("This Site");
siteSearch.setUserDefinedClassSuffix("siteSearch");
siteSearch.setSiteRestriction("almaer.com");
searchControl.addSearcher(siteSearch);

// Setup a search for the entire web
var webSearch = new GwebSearch();
webSearch.setUserDefinedLabel("Entire Web");
searchControl.addSearcher(webSearch);

// Setup a search for blogs
var blogSearch = new GblogSearch();
blogSearch.setUserDefinedLabel("Blogs");
searchControl.addSearcher(blogSearch);

// Setup the tabbed view
var drawOptions = new GdrawOptions();
drawOptions.setDrawMode(GSearchControl.DRAW_MODE_TABBED);

// Tell the searcher to draw itself and tell it where to attach
searchControl.draw(document.getElementById("searchcontrol"), drawOptions);
}
GSearch.setOnLoadCallback(OnLoad);

ajaxsearchapi.png

Read: Installing the Ajax Search API on this blog

Topic: JSR-277 Java Module System talk Previous Topic   Next Topic Topic: Fun in OpenID Land from PeopleOverProcess.com

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use