Main header

What is it?

Prototaglib is a JSP Tag library to make using the Prototype javascript library a bit easier. It's influenced from the Ruby on Rails approach.

Downloads

Screencast

Those familiar with the Ruby On Rails site may have seen the Ajax demo using the flickr api. You can watch the same sort of demo using the Prototaglib setup, using the FlickrJ api. The whole web app is also in the distribution zip/tar.gz file so you can see how it works. Watch the screen cast now.

Basic Tag Usage

  1. Place the prototaglib.tld file in your /WEB-INF folder then declare the taglib in your JSP page.
    <%@taglib uri="/WEB-INF/prototypetaglib.tld" prefix="prototype"%>
    
  2. Place your required javascript libraries in their own folder (just for neatness)
  3. Use prototaglib loadScripts tag to generate the <script> tags.
    <prototype:loadScripts scriptdir="js" libs="prototype, effects" />
    
    will produce...
    <script type="text/javascript" src="js/prototype.js"></script>
    <script type="text/javascript" src="js/effects.js"></script>
    
  4. Most developers will be interested in either triggering an Ajax call via a link or from a form. The link based tag is:
    <prototype:linkRemoteTag div="updatethis" hreftext="Click here to test." url="testajax.jsp" />
                
    <div id="updatethis">  
    </div>
    
    There are a number of attributes used: div specifies which div id to update. The url attribute is the the content that will populate within the div tag. hreftext is the text that appear as the link.