The Source for Java Technology Collaboration
User: Password:



Greg Murray's Blog

June 2006 Archives


Sun Joins Open AJAX Alliance and Dojo Foundation

Posted by gmurray71 on June 16, 2006 at 11:24 AM | Permalink | Comments (0)

If you have not seen the news today Sun has joined the open Open AJAX Alliance and the Dojo Foundation. This is great news as it shows that Sun is serious about working with other vendors on AJAX interoperability and working with the Dojo community to make sure it continues to be the best solution for AJAX development with Java.

I'm I am very glad to formalize our involvement with our Dojo community. We have been working with Dojo for some time with our Java Pet Store Demo which is based on Dojo, our AJAX Components, and Project jMaki all of which use Dojo. Going forward I'm looking forward to contributing to the momentum of Dojo and making it even better.

With the Open AJAX Alliance our hope is to work with the community at large to insure interoperability across JavaScript libraries, AJAX solutions, and browsers. This is great for the Java and AJAX communities.

I will be participating in both communities representing Sun and my hope is continue to drive solutions that provide the Java developer the best set of options for developing AJAX based applications.

Where would you like to see the happen Dojo and Open AJAX communities?



jMaki Google AJAX Search Component

Posted by gmurray71 on June 06, 2006 at 05:50 PM | Permalink | Comments (7)

The Google AJAX Search API allows you to include a dynamic Google search in to your web pages. jMaki can be used to provide Java developers a Java interface to the search API.

Here is what it takes to implement the Google AJAX Search API as a jMaki widget:

  1. Get a copy of the Glassfish Application Server. For more information about setting up your environment see the jMaki Developer documentation.
  2. Create a directory called gsearch. This directory will contain the HTML template file (component.htm) and the JavaScript bootstrap file (component.js)
  3. Create the component.htm HTML template file and place it in the "searchcomponent" directory. The contents of this file needs to be a single line:
    <div id="${uuid}"/>
  4. Create the component.js JavaScript bootstrap file and copy it into the "searchcomponent" directory. The contents of this file are similar to the contents provide in the Google AJAX Search API page. This file is called when the page is loaded and each widget is passed a JavaScript object "widget" which contains the parameters needed by the component instance and correspond to the parameters used by the component.htm template file. I used the following:
          // Create a search control
          var searchControl = new GSearchControl();
    
          // Add in a full set of searchers
          var localSearch = new GlocalSearch();
          searchControl.addSearcher(localSearch);
          searchControl.addSearcher(new GwebSearch());
          searchControl.addSearcher(new GvideoSearch());
          searchControl.addSearcher(new GblogSearch());
    
          // Set the Local Search center point
          localSearch.setCenterPoint(widget.args.centerPoint);
    
          // Tell the searcher to draw itself and tell it where to attach
          searchControl.draw(document.getElementById(widget.uuid));
    
          // Execute an inital search
          searchControl.execute("AJAX");
    
  5. Get an API key to use the example from http://code.google.com/apis/ajaxsearch/signup.html. This key has to match the directory from which you plan to use the component. I use http://localhost:8080/jmaki/google/.
  6. Add the Google Script to the WEB-INF/types.properties file containing the API key. The entry I added is as follows:
    googlesearch=http://www.google.com/uds/api?file=uds.js&v=0.1&key=YOUR_API_KEY _HERE
    

    Make sure to relace the API key with the one you got from Google.

  7. Create a JSP page that contains uses the tag. The page I used is as follows:
    <%@ taglib prefix="a" uri="http://java.sun.com/jmaki" %>
    
    <html>
    
    <head><title>Google Search Test</title></head>
    <h2>Google Search Test</h2>
    <hr>
    <a:ajax type="googlesearch" name="gsearch" args="{centerPoint: 'Santa Clara, CA'}" />
    
    </html>
    

    Note that an object literal is passed as the "args" attribute containing a property "centerPoint" with the value of "Santa Clara".

  8. Package and deploy your application. For more information about the application structure see jMaki Appications.

That is it! You now have a re-usable Google AJAX Search Widget. If you don't want to go through the steps download the jMaki Web application. The jMaki sample application contains more parameters you can set on the tag itself. If you get a chance give it a try.





Powered by
Movable Type 3.01D
 Feed java.net RSS Feeds