Apache
  Home arrow Apache arrow Apache Tapestry and Custom Components:...
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 
IBM Rational Software Development Conference
 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

Apache Tapestry and Custom Components: DateInput
By: Alexander Kolesnikov
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 10
    2007-06-19

    Table of Contents:
  • Apache Tapestry and Custom Components: DateInput
  • Creating the DateInput Component
  • Creating the Models
  • Wiring everything
  • Implementing PageBeginRenderListener

  • 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

    Save your reputation with your customers. Learn how you can have embedding success with Advantage Database Server (ADS).

    Apache Tapestry and Custom Components: DateInput
    (Page 1 of 5 )

    Tapestry has many benefits, but perhaps one of the most important is that it makes creation of custom components very easy. In this article, I'll create a custom component to illustrate this point.

    We are all different; we all have various ideas about how our application should look and work. Our customers have their own opinions and, well, sometimes prejudices too. As a result, at some time in your Tapestry development you will certainly come to the point when you'll find the existing choice of components insufficient, and you might want to create a component of your own.

    In a previous article we were playing with one of the core Tapestry components, DatePicker, and I tried to convince you that although this component is very good, it might not always be an ideal choice for date input. Today I am going to show you what I have done in a real development project when I needed an alternative way to accept a date input from the user.

    The process of creating Tapestry components is very similar to the process of creating Tapestry pages. As a page is typically represented by three files, say, Home.html for the template, Home.page for the specification and Home.java for the class, in the same way a component is typically represented by three files as well: say, SomeComponent.html for the template, SomeComponent.jwc for the specification (jwc extension means “Java Web Component”) and SomeComponent.java for the class.

    The only significant difference between components and pages is that components usually accept at least one parameter while pages don't. Everything else is very, very similar.

    Okay, that was enough propaganda; let's get some practical experience now. First of all, we need to visualize what exactly we want to achieve. As our Swiss customer with a massive C programming background can't bear a fancy DatePicker, we need to suggest something more traditional. Perhaps three drop-down lists for month, day and year input will do. This way, especially if we use not numbers but descriptive names for months, there will be no space for misinterpreting user input (as in that example – the 6th of December or the 12th of June?). Even if the user enters something like the 31st of February, by accepting the date in lenient mode we'll automatically convert it into the second or third of March, as the case may be.

    Here is a screen shot of what we want to create:

    As we don't want to place three PropertySelection components, configure them and then write some code to interpret them as one piece of input every time we need to accept a date from our user, what we need is a custom component. We want to be able to just drop it on a page and connect it to some property of the page class through the component's binding. Let's see how we can achieve this.

    More Apache Articles
    More By Alexander Kolesnikov


       · I know that the topic of creating custom components raises significant number of...
       · I think I tightly followed your code, but I still get an error when I try to...
       · Check if the 'date' binding of the DateInput is actually bound to something in the...
       · Hi :)I have built the component where one introduces the address. How I can pass...
       · I am not completely sure what you mean, but it sounds like you could have an Address...
       · I have the same problem. There is [i]public abstract Date getDateOfBirth();[/i]...
       · Sorry, I see the mistake. Not `name="value"` but `name="date"`.
       · Sorry for not answering in time - I am completing a book on Tapestry 5 and working...
       · Sorry for not continuing the tutorial for a while. A publisher contacted me and...
       · It's a pleasure to learn Tapestry with your great tutorial!I'm truely looking...
       · It seems that some people dont like to use the specifications page and like to make...
     

       

    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




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