Apache
  Home arrow Apache arrow Page 2 - 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 Developerworks
 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
     
     
    CIO Insight
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Apache Tapestry and Custom Components: DateInput - Creating the DateInput Component
    (Page 2 of 5 )

    Let the name for our custom component be DateInput – quite descriptive for its purpose. So the three files associated with this component will be DateInput.html, DateInput.jwc and DateInput.java. We can simply add these files to the existing CelebrityCollector project, in the same way we added pages to it before. We might decide to use this new DateInput as a replacement for the DatePicker component.

    The first step is to create an HTML template, DateInput.html file. It is actually a fragment of HTML we want to be included into an HTML page when the component renders itself, but it will often make sense to create the component template as a complete standalone HTML page so that we can easily preview it in any browser:

    <html>

       <head>

           <title>DateInput Template</title>

       </head>

       <body>

           <select>

              <option>January</option>

              <option>February</option>

           </select>

           <select>

              <option>1</option>

              <option>2</option>

           </select>,

           <select>

              <option>2005</option>

              <option>2006</option>

           </select>

       </body>

    </html>

    Now let's convert this mock up into a Tapestry template. All three <select> elements should obviously be marked as Tapestry components, but there is also one other thing to do. We made the template a complete HTML page, but we don't want all those surrounding <html>, <head> etc. tags to be inserted somewhere in the middle of another page.

    Fortunately, Tapestry has a special tool that allows us to do exactly what we want, and very easily. Have a look at this template:

    <html>

       <head>

           <title>DateInput Template</title>

       </head>

       <body jwcid=”$content$”>

           <select jwcid="month">

                <option>January</option>

                <option>February</option>

       </select>

            <select jwcid="day">

                <option>1</option>

                <option>2</option>

       </select>,

       <select jwcid="year">

                <option>2005</option>

                <option>2006</option>

       </select>

       </body>

    </html>

    Note the jwcid=”$content$” attribute, used here to mark the <body> element. It tells Tapestry that anything surrounded by this element should be taken seriously (i.e. rendered at runtime) while everything else, the <body> itself and everything that surrounds it, should be discarded.

    The next step is to create a component specification. It looks very similar to a page specification:

    <?xml version="1.0" encoding="UTF-8"?>

    <!DOCTYPE component-specification PUBLIC

       "-//Apache Software Foundation//Tapestry Specification 4.0//EN"

       "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd">

     

    <component-specification

       class="com.devshed.tapestry.celebrities.DateInput">

      

        <description>Component for choosing a date</description>

       

        <component id="day" type="PropertySelection">

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

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

        </component>

        <component id="month" type="PropertySelection">

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

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

        </component>

        <component id="year" type="PropertySelection">

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

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

        </component>

       

    </component-specification>

    In fact, the only difference is the name of the root element: it is now <component-specification> instead of <page-specification>. Otherwise, the specification is exactly the same as it would be for a Tapestry page with three PropertySelection components in it.

    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

     
    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 6 hosted by Hostway