Geertjan's Blog

  • May 14, 2006

Eight jMaki Samples

Geertjan Wielenga
Product Manager
Install this in NetBeans IDE 5.5:


When you do that, you'll find this in the New Project wizard:

So, these are jMaki samples. They're from the jMaki Project's sources; all I've done is create NetBeans projects for them. All of them can be deployed as soon as you finish the wizard, because they all work on Tomcat and that is the server that is bundled with the IDE. The only one that has problems on Tomcat (for reasons I don't understand) is the one I blogged about yesterday—the Scriptaculous In Place Editor sample. (It works fine on Glassfish.) All the others work on Tomcat. Another thing to understand is that I haven't packaged the jMaki classes in a JAR file—they're all exposed in each sample's Source Packages folder; so they're editable, although that is unnecessary. You can look at them there, but I just haven't figured out how to JAR them correctly. That's the only reason why they aren't in a JAR file attached to each sample. The Yahoo Calendar has one problem—you can't move from month to month, but I'm not sure if that functionality is provided in the sample at all (and so I'm not sure if I did something wrong or if the sample came that way).

As an example of what you'll get when you click Finish in the New Project wizard, here's the Projects window for the jMaki Sudoku Game sample:

Things to notice in the screenshot above:

  • The sudoku widget. As discussed in yesterday's blog (and elsewhere), jMaki is all about wrapping JavaScript. Well, that's what the widget (also known as "component") does. It consists of the files that you find in the sudoku folder above. Or, here's another way to look at it (from Creating jMaki Widgets):

  • The index.jsp file. This file is displayed upon deployment. It provides links that branch off to two versions of the Sudoku game—sudoku.jsp and sudoku2.jsp. Both of these make use of a tag that references, via the tag library descriptor component.tld, the sudoku widget described above. For example, this is what sudoku.jsp looks like (note the lines in bold):

    <%@ taglib prefix="a" uri="http://java.sun.com/jmaki" %>
    <h1>Sudoku Test</h2>
    <a:ajax name="sudoku"/>

And that's all that you really need to know, if you're a user of the widget. In that case, all you need is the tag in the JSP file. As a developer of the widget, you need to know how to put the widget together. But even if you're the widget developer, you already have the jMaki library (here, as pointed out, erroneously available as editable files in the Source Packages folder). You also always have the jmaki.js file, which performs actions like widget bootstrapping.

Give the samples a try. One of my favorites is the jMaki List sample. Here, as you can see below, you can add items to a list. But the cool part is that when you move the mouse over an item, it is highlighted as shown below. Even better—when you click on a selected item, it is deleted. Pretty powerful. Here's the screenshot, to give some context:

So, if you're interested in AJAX, and want to make your life a lot easier, I'd recommend giving Project jMaki a chance. And what better place to start than with a bunch of samples?

Join the discussion

Comments ( 8 )
  • Petr Jiricka Monday, May 15, 2006
    Great, works for me! There is just one minor bug, when I open index.jsp in the editor, I get an error message: Unable to load tag handler class "com.sun.jmaki.AjaxTag" for tag "a:ajax".
  • Geertjan Monday, May 15, 2006
    Yeah, it is strange. I've seen it too. When you press Enter at the start of the line where the tag appears, thus putting it in a new line, the error disappaears. (But whether or not that error is displayed, you can still deploy successfully.) I think it is maybe some refresh bug in the JSP editor.
  • Geertjan Monday, May 15, 2006
    More precisely: You need to deploy the application (which, despite the error, deploys successfully) and THEN put the tag on a new line. Then the error vanishes.
  • guest Tuesday, July 18, 2006
    is there anybody out htere
  • guest Wednesday, February 21, 2007
  • guest Saturday, March 31, 2007
  • guest Monday, June 18, 2007
  • sahil Friday, June 13, 2008

    hey it was very helpful!!!

    but i m findin d same error of missing tag library for 'a'.

    n deployd pgm gives error!!!

    pls do suggest a remedy!!

Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.