Apache
  Home arrow Apache arrow Tapestry and AJAX: Autocompleter and I...
Dev Shed Forums 
Administration  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
APACHE

Tapestry and AJAX: Autocompleter and InlineEditBox
By: Alexander Kolesnikov
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 9
    2007-06-18

    Table of Contents:
  • Tapestry and AJAX: Autocompleter and InlineEditBox
  • The IAutocompleteModel interface
  • Enabling JavaScript
  • Meet InlineEditBox

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
     
    ADVERTISEMENT

    Dell PowerEdge Servers

    Tapestry and AJAX: Autocompleter and InlineEditBox
    (Page 1 of 4 )

    Although the term "AJAX" was coined not so long ago, AJAX-like functionality has already been available in Tapestry for quite some time. In Tapestry 4.0 we can use Tacos, a rich and interesting library of custom Tapestry components that includes a number of AJAX-driven components. Tapestry 4.1 has Dojo JavaScript library built into it, so it comes with some core AJAX-enabled components.
    A downloadable zip file is available for this article.

    The essence of AJAX is that we don't need to request the whole page from the server every time we want to change it. Instead, the page contains some clever dynamic things in it (with Tapestry these things are AJAX-enabled components) that can communicate with the server behind the scenes and redisplay themselves with new information quickly and smoothly in some clever way.

    The benefit of Tapestry AJAX components is that you can use AJAX without any knowledge of JavaScript whatsoever. Components encapsulate everything required for their work, and you only need to configure their required bindings. Well, in fact there is one additional chore when dealing with AJAX components: you have to make JavaScript libraries available to the page. For this, you'll have to use Shell and Body components in the same way as we did it for DatePicker in one of the previous articles.

    I decided to introduce one of Tapestry's AJAX components now because Autocompleter is quite similar to the PropertySelection component we dealt with in the previous article. It has the same two required bindings, model and value, and its model is an implementation of a special interface with a few methods for us to implement. So it shouldn't be too difficult.

    The idea is to propose to the users of the CelebrityCollector application an alternative way of selecting a Celebrity of the Week. We don't want to keep them desperately searching a long list of celebrities trying to find their favorite. Instead, they will enter the first few characters of their favorite's surname into the Autocompleter, and this clever component, after an invisible rendezvous with the server, will suggest a list of available surnames starting from the entered characters. Here is the result we want to achieve:

    As usual, let's begin with a mock up. Here is the old form for selecting a Celebrity of the Week:

    <form action="" jwcid="@Form">

      <select jwcid="selectCelebrity">

        <option value="1">Angelina Jolie</option>

        <option value="2">Bill Gates</option>

      </select>

      <input type="submit" value="Save"/>

    </form>

    Change it to become

    <form action="" jwcid="@Form">

      <select jwcid="selectCelebrity">

        <option value="1">Angelina Jolie</option>

        <option value="2">Bill Gates</option>

      </select><br/><br/>

      <input type="text" jwcid="auto"/><br/><br/>

      <input type="submit" value="Save"/>

    </form>

    The addition is very simple: we use a text box as a placeholder for the future Autocompleter, and it is marked as a Tapestry component. The next step is to configure this component in the page specification:

    <component id="auto" type="Autocompleter">

      <binding name="model" value="autoModel"/>

      <binding name="value" value="celebrityOfTheWeek"/>

    </component>

    It looks very similar to PropertySelection, doesn't it? It connects straight to the ASO, in the same way as the PropertySelection does, but its model should implement a different interface, the IAutocompleteModel.

    More Apache Articles
    More By Alexander Kolesnikov


       · I think this is one of the greatest features of Tapestry: you can make use of AJAX...
       · Very cool!Autocompleter is awesome but the InlineEditBox didn't seem to work...
       · Well, I do have InlineEdit running successfully, as screenshots show. Did you try...
       · Yes. I download the src, create a new net beans web app from existing source, add...
       · Okay, I've got a demonstration for you. I have deployed CelebrityCollector to my...
       · I tested it out in IE 6 and Firefox 2 on your site (sundraw) and it behaves (for me)...
       · Ufff... So this is what you meant by not working InlineEdit. Well, the problem you...
     

       

    APACHE ARTICLES

    - Putting Apache in Jail
    - Containing Intrusions in Apache
    - Server Limits for Apache Security
    - Setting Permissions in Apache
    - Installing Apache
    - Apache Installation and Configuration
    - Apache Tapestry and Custom Components: DateI...
    - Tapestry and AJAX: Autocompleter and InlineE...
    - PropertySelection and IPropertySelectionMode...
    - The DatePicker and Shell Components of Apach...
    - Apache Tapestry: ASO and More Components
    - Apache Tapestry and DirectLink, IoC and DI
    - Making a CelebrityCollector with Apache Tape...
    - Apache Tapestry and Listener Methods, Condit...
    - The Properties of Tapestry Pages

     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway