Using jMaki Technology for Building Web 2.0/Ajax Applications

Contributed and maintained by Sang Shin & Doris Chen, Sun Microsystems, www.javapassion.com/ajaxcodecamp


jMaki is all about enabling Java developers to use JavaScript in their Java based applications as either a JSP tag library or a JSF component. jMaki uses the best parts of Java and the best parts of JavaScript to deliver a rich Ajax style widgets.  jMaki currently provides bootstrap widgets for many components from Dojo, Script.aculo.us, Yahoo UI Widgets, Spry, DHTML Goodies, and Google. jMaki provides a common interfaces to these widget libraries and allows you to use these libraries together in the same page.

This hands-on lab takes you through the basics of using jMaki widgets for developing highly responsive and interactive AJAX-based web applications. This document is designed to get you going as quickly as possible.


Expected duration: 120 minutes

Prerequisites

This hands-on lab assumes you have some basic knowledge of, or programming experience with, the following technologies.

Software Needed

Before you begin, you need to install the following software on your computer. 



Change Log



Lab Exercises



Exercise 0: Installation and Configuration

In this exercise, you are going to install jMaki NetBeans Plug-in first.  Also you are going to configure Mozilla Firefox browser to be the default browser of NetBeans IDE.  Make sure you have downloaded and installed the software mentioned above before you start. 

    1. Install jMaki NetBeans Plug-in to the NetBeans IDE
    2. Configure Firefox browser as default browser of NetBeans IDE (if you have not done so yet)
    3. Install Firebug debugger to the Firefox browser (if you have not done so yet)

(0.1.a) Install jMaki NetBeans Plug-in to the NetBeans IDE (if you have an internet connection)


1. Select Tools from the top-level menu and select Plugins. (Figure-0.17 below)


Figure-0.17: Select Tools->Plugins

2. Click Available Plugins tab window and then select jMaki AJax Support.
3. Click Install button. (Figure-0.18 below)


Figure-0.18: Install jMaki Ajax Support plug-in

4.  Click Next. (Figure-0.19 below)


Figure-0.19: NetBeans IDE Installer

5. Check "I accept the terms ..". (Figure-0.20 below)
6. Click Install.


Figure-0.20: Accept the license

7. Check "Restart IDE Now". (Figure-0.21 below)


Figure-0.21: Restart the IDE


(0.1.b) Install jMaki plug-in to the NetBeans (if you do not have an internet connection)


In case you don't have an internet connection, the jMaki NetBeans plug-in is provided in the hands-on lab zip file as <LAB_UNZIPPED_DIRECTORY>/benchmarkwebapp/jMakiPlugin/org-netbeans-modules-sun-jmaki.nbm

1. Select Tools from the top-level menu and select Plugins. (Figure-0.17 above)
2. Select Downloaded tab window.
3. Click Add Plugins. (Figure-0.22 below)


Figure-0.22: Add Plug-in from local file system

4. Drill down to <LAB_UNZIPPED_DIRECTORY>/benchmarkwebapp/jMakiPlugin directory.
5. Select org-netbeans-modules-sun-jmaki.nbm and click Open button. (Figure-0.23 below)


Figure-0.23: Select jMaki plug-in

6. Follow the instruction of the installation.


(0.2) Configure Firefox browser as default browser of NetBeans IDE (if you have not done so yet)


In this step, you are going to select the Firefox browser as the default browser of the NetBeans IDE.  What this means is that every time a browser is started by the NetBeans, the Firefox browser will be displayed.

1. Start NetBeans IDE.
2. Select Tools from the top-level menu bar of NetBeans IDE.
3. Select Options. The Options dialog box appears.
4. Select Firefox for the Web Browser.
5. Click OK to close the Options dialog box. (Figure-0.14 below)


Figure-0.14: Configure Firefox as default browser for the NetBeans

                                                                                                                        return to the top



Exercise 1: Explore jMaki Widgets using jMaki demo application

In this exercise, you are going to build and run a jMaki demo application, through which you can play around and explore various widgets supported by jMaki technology.  This application can be accessed online from here.


(1.1) Build and run jMaki demo application

0. Start NetBeans IDE (if you have not done so yet)
1. Create a new jMaki NetBeans project


Figure-1.10: Create Web Application with Existing Sources

Figure-1.11: Select Existing Source Location

Figure-1.12: Project Folder already contains


Figure-1.14: Existing Sources and Libraries pane

2. Run the project.


Figure-1.15: Run jMakiDemo project

Figure-1.16: jMaki demo application

                                                                                                                        return to top of the exercise

(1.2) Play around with DHTML Goodies Widgets

In this step, you are going to play around with DHTML Goodies Widgets.

1. Try Sliding Menu widget


Figure-1.20: Sliding Menu widget

Figure-1.21: DHTML Goodies Sliding Menu Test

2.  Try Tooltip widget

Figure-1.22: Tooltip test

3. Change the message content of the Tool Tip box

Figure-1.23: Tooltip widget

Figure-1.24: Provide your own tooltip.

Figure-1.25: Observe that your own tooltip is used

                                                                                                                        return to top of the exercise

(1.3) Play around with Dojo Widgets


In this step, you are going to play around with Dojo Widgets.

1. Try Editable Table widget

Figure-1.30: Explore Editable Table widget

Figure-1.31: Sort the table

Figure-1.32: Edit the table field

2. Change the table content of the Editable Table Widget.

Figure-1.33: Editable table widget
{
"columns": { "title" : "Title", "author":"Author", "isbn": "ISBN #", "description":"Description"},
"rows":[
 ['Life is good', 'Doris Chen','441234', 'You must be kidding!'],
 ['Save the earth', 'Me','441322', 'Some long description'],
 ['The Sun rises again','Whoever', '441234','Yes, indeed'],
 ['javapassion.com', 'Sang Shin', '441335', 'Some long description'],
 ['passion', 'Sang Shin', '451335', 'Some long description']
 ]
}
Code-1.34: Modified contents of books.json

Figure-1.34: New table contents

3. Try Editable Table widget using JSF tag
4. Take a look at the JSP page that uses JSF tag

Figure-1.35: etable-jsf.jsp

5. Try Fish Eye List Dojo widget.

Figure-1.36: Fish Eye List widget

6. Add a few more Fish Eye List items
<%@ taglib prefix="a" uri="http://java.sun.com/jmaki" %>

<h2>Dojo Fish Eye List Test</h2>
<a href="index.jsp">Back to Samples</a>
<hr>

    <a:ajax name="dojo.fisheye"
            args="{items:[
                  {iconSrc:'images/JayashriVisvanathan.jpg',caption:'Jayashri', index:1},
                  {iconSrc:'images/chinnici.jpg',caption:'Roberto',index:2},
                  {iconSrc:'images/blog_murray.jpg',caption:'Greg',index:3},
                  {iconSrc:'images/edburns.jpg',caption:'Ed',index:4},
                  {iconSrc:'images/icon_browser.png',caption:'You are here!',index:5},
                  {iconSrc:'images/icon_calendar.png',caption:'my caption2',index:6},
                  {iconSrc:'images/icon_update.png',caption:'passion',index:7}
            ]}"

    />


<script type="text/javascript">

  function fisheyeListener(item) {
      var targetDiv = document.getElementById("newpage");
      var responseText = "";
     var index = Number(item.index);
      switch(index){
        case 1:  responseText += '<img src="images/JayashriVisvanathan.jpg"/><p>I am Jayashri Visvanathan and I work on Java Studio Creator. My area of interest/expertise is JSF components. Before I joined Creator team, I used to work on the JSF Reference Implementation (RI). I have been part of JSF team since its inception and have contributed to various releases including the current release JSF 1.2. I was also managing the JSF project on java.net since its launch. Prior to joining the JSF team, I worked on various client and server side web products/technologies within Sun including Mozilla, WebTop Registry Server and HotJava Browser.';
    break;
        case 2:  responseText +='<img src="images/chinnici.jpg"/><p>Roberto Chinnici is a senior staff engineer at Sun Microsystems, Inc. where he works on the Java™ Platform, Enterprise Edition, with particular focus on Web Services and Ease of Development. He is the specification lead for the JAX-RPC 1.1 and JAX-WS 2.0 technologies, both developed under the Java Community Process. He is also Sun\'s principal representative in the Web Services Description Working Group at W3C and has been a member of the WS-I Basic Profile Working Group. Mr. Chinnici holds an M.S. in Computer Science from the University of Milan, Italy.';
    break;
        case 3: responseText += '<img src="images/blog_murray.jpg"/><p>Appointed as AJAX Architect for Sun Microsystems, Greg Murray is deeply involved in the AJAX movement through his participation in the OpenAJAX Alliance and contributions to the Dojo Foundation\'s open-source JavaScript toolkit. Within Sun, Greg lead a grass roots effort advancing the integration of client-side scripting with Java technologies and is the creator and principal architect of Project jMaki. jMaki uses the best parts of Java and the best parts of JavaScript to deliver rich AJAX style widgets through a singe, easy-to-use interface that accesses components from popular widget libraries such as Dojo, Script.aculo.us, Yahoo\'s UI Library, Spry, DHTML Goodies, and Google\'s Web Toolkit. Greg recently contributed to the design and development of the AJAX-based Java Pet Store 2.0 Demo and helped create Java BluePrints solutions for using AJAX with Java technologies.';
    break;
        case 4: responseText += '<img src="images/edburns.jpg"/><p>Ed Burns is a senior staff engineer at Sun Microsystems. Ed has worked on a wide variety of client and server side web technologies since 1994, including NCSA Mosaic, Mozilla, the Sun Java Plugin, Jakarta Tomcat and, most recently JavaServer Faces. Ed is currently the co-spec lead for JavaServer Faces.  Ed has contributed JSF support to jMaki in the form of bug-fixes, nags, and tersely worded emails.</p>';
    break;
    default: responseText += 'Click on one of the photos above';
    break;
      }
      targetDiv.innerHTML = responseText;
  }
  jmaki.subscribe("/dojo/fisheye", fisheyeListener);
</script>
<p>
<h3><div id="newpage"></div></h3>
Code-1.37: Modified fisheye.jsp

Figure-1.38: Newly added Fisheye items

7.  Try other Dojo widgets.
                                                                                                                        return to top of the exercise

(1.4) Play around the rest of the Widgets


Play around other widgets from the jMaki demo applications.



Summary

In this exercise, you have built and run jMaki demo sample application  through  which you  explored  the usage of various widgets.  You also see how these widgets are represented as JSP and JSF tags.
   
                                                                                                                                   Return to the top


Exercise 2: Build your own application using various jMaki widgets

In this exercise, you are going to build a Web application using jMaki widgets including Dojo Fish Eye List widget.  You will learn how to configure a widget using widget customizer.  You will also learn how to choose CSS layout for your application.

  1. Create and run an application that uses jMaki Dojo Fish Eye List widget
  2. Try widget customizer
  3. Try different CSS layouts

(2.1) Create and run an application that uses jMaki Dojo Fish Eye List widget

0. Start NetBeans IDE if you have not done so yet. 
1. Create a new jMaki NetBeans project


Figure-2.10: Create Web Application project


Figure-2.11: Give a project name

Figure-2.12: Select jMaki Ajax Framework and CSS Layout

Figure-2.13: jMakiFisheye project is created


Trouble-shooting: If for some reason, you don't see the Palette, it is highly because you closed the Palette window before. 
Solution: In order to reopen the Palette, select Window from the top-level menu and then select Palette.


2. Add Dojo Fish Eye List widget to the application

Figure-2.14: Fish Eye idget is added to the application

Since you might be running this application without internet access, we will modify the index.jsp to use locally available images.

3. Copy images directory from jMakiDemo project to the jMakFisheye project.

Figure-2.15: Copy images

Figure-2.16: Paste the images

4. Modify images sources of the Fish Eye jMaki tag to use locally available images.
<%@ taglib prefix="a" uri="http://jmaki/v1.0/jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html>
    <head>
        <link rel="stylesheet" href="jmaki-standard-no-sidebars.css" type="text/css"></link>
        <title>Page Title</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    </head>
    <body>
        <div id="outerBorder">
           
            <div id="header">
                <div id="banner">Application Name</div>
               
                <div id="subheader">
                   
                    <div>
                        <a href="mailto:feedback@youraddress">Feedback</a> |
                        <a href="#">Site Map</a> |
                        <a href="#">Home</a>
                    </div>
                </div> <!-- subheader  -->

            </div> <!-- header -->

            <div id="main">
               
                <div id="content" style="height:400px">
                   
                    Main Content Area
                    <a:widget name="dojo.fisheye"
                              value="[
                            {iconSrc:'images/icon_browser.png',caption:'browser', index:1},
                            {iconSrc:'images/icon_calendar.png',caption:'calendar', index:2},
                            {iconSrc:'images/icon_email.png',caption:'email',index:3},
                            {iconSrc:'images/icon_texteditor.png',caption:'text editor',index:4},
                            {iconSrc:'images/icon_update.png',caption:'update',index:5}
               
                              ]"/>
                             
                </div> <!-- content -->
            </div> <!-- main -->

        </div> <!-- outerborder -->
    </body>
</html>
Code-2.17: Use locally available images.

5. Build and run the application.

Figure-2.18: Fish Eye

                                                                                                                        return to top of the exercise

(2.2) Try widget customizer

In this step, you are going to see how to configure each widget through widget Customizer.

1. Right click any point in the widget tag and select jMaki.  (Figure-2.20 below)


Figure-2.20: See jMaki customizer of the Dojo Fish Eye List widget

2. Observe that the Properties pane of the dojo.fisheye Customizer dialog box appears.  Read Description of each argument. (Figure-2.21 below)


Figure-2.21: dojo.fisheye Customer, Properties

3. Click Usage tab.  (Figure-2.22 below)


Figure-2.22: Usage of the dojo.fisheye

                                                                                                                        return to top of the exercise

Exercise 3: Build a Web application using various jMaki widgets

In this exercise, you are going to build a Web application using various widgets

(3.1) Build a Web application using various jMaki widgets from different sources


In this step, you are going to use different widgets using various CSS layouts.

1. Create a new jMaki NetBeans project

Figure-2.29: Create a new Web Application project

Figure-2.30: Three Column layout

2. Add widgets to the Three Column layout

Figure-2.31: Add 3 widgets to three column CSS layout

3.  Build and run the project

Figure-2.32: Three column format

4. Remove  the height attributes from the widgets.

Figure-2.34: Remove height attributes

5.  Click Save All button to save the change. (Figure-2.35 below) Note your don't have to rebuild or rerun the project.


Figure-2.35: Save the changes

6. From the browser, click Refresh button to see the change. (Figure-2.36 below)


Figure-2.36: Change is reflected.


                                                                                                                        return to top of the exercise



Summary

In this exercise,  you have built and run a couple of sample applications using various jMaki widgets that are available from jMaki NetBeans plug-in.  You also tried different CSS layouts.

                                                                                                                        return to the top



Exercise 4: Understanding jMaki Scriptaculos Inplace widget

In this exercise, you are going to build and run a sample jMaki application that uses Scriptaculous Inplace widget.  You will then see how the widget is made of.  The Inplace widget is chosen for this exercise since it is one of the simplest widgets.  In Exercise 5, you are going to build your own HelloWorld widget.

    1. Create and run jMaki application that uses Inplace widget
    2. Look under the hood of Inplace widget
    3. See how the Inplace widget is used


(4.1)  Create and run jMaki application that uses Inplace widget

0. Start NetBeans IDE if you have not done so yet. 
1. Create a new jMaki NetBeans project


Figure-4.10: Create jMakiInplace project



Figure-4.11: Use jMaki Ajax Framework
2. Add jMaki Inplace widget to the application

Figure-4.12: Inplace widget is added

3. Build and run the application.

Figure-4.13: Running jMaki application that uses Inplace widget









                                                                                                                        return to top of the exercise



(4.2)  Look under the hood of the Inplace widget


In this step, you will look under the hood of the Inplace widget you used above.  Note that each widget is made of the following files.
1.  See what make up the Inplace widget.

Figure-4.20: Inplace widget has list directory with necessary files

2. Study component.css of the Inplace widget.

The component.css defines the style of the widget. 
.selected { background-color: #888; }
Code-4.21: component.css

3. Study the component.htm of the Inplace widget.

<Learning point> Each widget instance in a page will be assigned a uuid (Universally Unique Identifier) by the jMaki framework.  In the component.htm, it is represented by ${uuid}
<a id="${uuid}" href="#">${value}</a>
Code-4.22: component.htm

4. Study the component.js of the Inplace widget.
/* Copyright 2007 You may not modify, use, reproduce, or distribute this software except in compliance with the terms of the License at:
 http://developer.sun.com/berkeley_license.html
 $Id: component.js,v 1.0 2007/04/15 19:39:59 gmurray71 Exp $
*/
// define the namespaces
if (!jmaki.widgets.scriptaculous) {
    jmaki.widgets.scriptaculous = {};
}
jmaki.widgets.scriptaculous.inplace = {};

/**
 * @constructor
 */
jmaki.widgets.scriptaculous.inplace.Widget = function(wargs) {
    var wInstance = this;
   
  var service;
  if (!wargs.service) {
        jmaki.log("You did need to provide a service for the completer to use. Defaulting to an _inplace.html file in the widget directory.");
     service =  wargs.widgetDir + "/_inplace.html";
  } else service = wargs.service;

  this.wrapper = new Ajax.InPlaceEditor(wargs.uuid, service,
  { ajaxOptions:
        {method: 'post'},
        widget: wargs,
        callback: function(form, value) {
        var result = null;
      wInstance.wrapper.value = value;
      jmaki.publish("/scriptaculous/inplace/valueUpdate",
            {target:wInstance, wargs:wargs, value : value});
      if (null != wargs.outResult) {
          result = wargs.outResult;
      }
      else {
          result = Form.serialize(form);
          if (!wargs.service) wInstance.wrapper.element.innerHTML = value;
      }
      return result;
      },
      onComplete: function(transport, element) {
            element.innerHTML = wInstance.wrapper.value;
        if (null == transport || null == element) {
        return;
        }
        jmaki.publish("/scriptaculous/inplace/response",
              {target:wInstance, wargs:wargs, transport:transport,
               element:element});
      }

  });
}
Code-4.23: component.js

4. Study the widget.js of the Inplace widget.

{
    'name': 'Inplace',
    'type': 'scriptaculous',
    'version': '1.0',
    'jmakiVersion': '1.0',   
    'image': 'images/scriptaculus-inplace.jpg',
    'description': 'A autocomplete widget.',
    'value': {
        'required':'true',
    'type': 'STRING',
    'defaultValue': 'click me to replace me'
    },
    'config' : {
        'type' :
    {'id': 'scriptaculous',
         'version': '1.6.4',
         'libs': [
                  '../resources/libs/scriptaculous/v1.6.4/prototype.js',
                  '../resources/libs/scriptaculous/v1.6.4/scriptaculous.js',
                  '../resources/libs/scriptaculous/v1.6.4/dragdrop.js',
                  '../resources/libs/scriptaculous/v1.6.4/effects.js',
                  '../resources/libs/scriptaculous/v1.6.4/builder.js',
                  '../resources/libs/scriptaculous/v1.6.4/slider.js',
                  '../resources/libs/scriptaculous/v1.6.4/controls.js'
                 ],
    'resources': 'services/inplaceService.jsp'
        }
    },
    'topicInfo': {
    'type': 'publish',
    'topicName': '/scriptaculous/inplace/valueUpdate',
    'description':'publish to topicName when the value is updated.  If there is a service, publish to /scriptaculous/inplace/response on onComplete event'
    }
}


                                                                                                                        return to top of the exercise


 

Summary

In this exercise,  you have built and run a simple jMaki application using Inplace widget first.  You then learned a widget is made of three files - component.css for styling, component.htm for display, and component.css for behavior.

                                                                                                                        return to the top


Exercise 5: Creating your own HelloWorld jMaki widget

In this exercise, you are going to create a simple "HelloWorld" jMaki widget of your own.   The "HelloWorld" jMaki widget is a input text field with AJAX behavior - whatever you type in the input text field will be redisplayed with "Hello, <whatever-you-typed>!" almost immediately. 

    1. Create "jMakiHelloWorld" project
    2. Create template files for the HelloWorld jMaki widget
    3. Create helloService.jsp
    4. Create index.jsp
    5. Build and run the application


(5.1)  Create "jMakiHelloWorld" project


0. Start NetBeans IDE 6.0. (If you have not done so yet)
1. Create a new jMaki NetBeans project
                                                                                                                        return to top of the exercise


(5.2)  Create jMaki template files for the HelloWorld jMaki widget


In this step, you are going to create the following three template files under jMakiHelloWorld->Web Pages->resources->helloworld directory.  The resources directory maintains all the jMaki widgets.
1.  Create helloworld folder under resources.

Figure-5.21: Create a new folder

Figure-5.22: Create a new folder

Figure-5.23: Create helloworld folder

2. Create component.htm template file

Figure-5.24: Create Empty File

Figure-5.25: Give it a file name
<form>
 <input id="${uuid}_name" type="text" size="20" value="Enter your name"
            onkeyup="jmaki.attributes.get('${uuid}').submitData()">
</from>

<div id="${uuid}_hello" class="helloDiv"></div>
</div>
Code-5.22: component.htm of the HelloWorld jMaki widget

3.  Create component.css file

Figure-5.23: Create component.css
.plain {
 color: black;
 height:25;
 font-size:18px;
 font-weight: bold;
 font-family: Arial;
 background: white;
}

.over {
 color: white;
 height:25;
 font-size:18px;
 font-weight: bold;
 font-family: Arial;
 background: blue;
 cursor: pointer;
}


.helloDiv {
    position: relative;
    width: 400px;
    height: 300px;
    overflow: auto;
}
Code-5.24: component.js of the HelloWorld jMaki widget

4. Create component.js

// define the namespaces
if (!jmaki.widgets.jmaki) {
    jmaki.widgets.jmaki = {};
}
jmaki.widgets.jmaki.helloworld = {};

jmaki.widgets.jmaki.helloworld.Widget = function(wargs) {
    // The jMaki framework must have created widget JavaScript object.
    var uuid = wargs.uuid;
    var service = wargs.service;
  
    function getXHR(url) {
        if (window.XMLHttpRequest) {
            return new XMLHttpRequest();
        } else if (window.ActiveXObject) {
            return new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
  
    // This function gets called when a user typed some characters
    // in the input text field whose id is set as ${uuid}_hello in
    // component.htm template file.
    this.submitData = function() {
        var target = document.getElementById(uuid + "_hello");
        var req = getXHR(service);
        req.onreadystatechange = function() {
            if (req.readyState == 4) {
                if (req.status == 200) {
                    target.innerHTML = req.responseText;
                }
            }
        };
        req.open("POST", service, true);
        var name= document.getElementById(uuid + "_name");
        req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        req.send("name=" + name.value + "&uuid=" + uuid);
    }
  
}
Code-5.25: component.js of the HelloWorld jMaki widget

                                                                                                                        return to top of the exercise



(5.3) Create helloService.jsp


In this step, you are going to create a service page called helloService.jsp.

1. Create helloService.jsp

Figure-5.30: helloService.jsp

2. Replace the IDE generated  helloService.jsp file with the code in Code-5.31 below.

<ol>
<%
String name= request.getParameter("name");
out.println("Hello, " + name + "!");
%>
</ol>
Code-5.31: helloService.jsp


Figure-5.32: helloService.jsp

                                                                                                                        return to top of the exercise

(5.4) Modify index.jsp


In this step, you are going to modify the index.jsp to use the HelloWorld jMaki widget you just created.

1. Modify the index.jsp under jMakiHelloWorld->Web Pages as shown in Code-5.32 below.  The code fragment that needs to be added is highlighted in bold and blue-colored font.

<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>

<%@ taglib prefix="a" uri="http://java.sun.com/jmaki" %>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>

        <h1>Use my own HelloWorld jMaki widget</h1>
        <a:ajax name="helloworld"   service="helloService.jsp"  />

    </body>
</html>
Code-5.32: Modified index.jsp

                                                                                                                        return to top of the exercise



(5.5) Save the changes and refresh the browser


1. Right click jMakiHelloWorld and select Run Project.
2. In the text field, type something like Sang Shin (without pressing Enter key) as shown in Figure-5.50 below  
3. Observe that Hello, Sang Shin! message should get displayed. 


Figure-5.50: Observe that the values typed in are redisplayed

4. See the values of the request and response.

Figure-5.51: Result of running an application that uses HelloWorld jMaki widget

Figure-5.52: See the value that is returned from the server

                                                                                                                        return to top of the exercise



Solution


The solution to this exercise is provided as a ready-to-open-and-run NetBeans project as part of hands-on lab zip file. You can find it under <LAB_UNZIPPED_DIRECTORY>/ajaxjmakiintro/solutions/jMakiHelloWorld-solution.  You can just open it as a NetBeans project and run it. 

Summary


In this exercise, you have created your own jMaki widget called helloworld and used it in your application. You also observed the Ajax-based behavior of the helloworld wiget through Firebug debugger.


                                                                                                                        return to the top



Homework exercise (for people who are taking Sang Shin's "AJAX online course")


1. The homework is to create a new jMaki widget of your own by slightly modifying the helloworld jMaki widget you built above as following:
2. Send the following files to ajaxhomework@sun.com with Subject as AJAXHomework-ajaxjmakiintro.