Apache
  Home arrow Apache arrow Page 4 - PropertySelection and IPropertySelecti...
CIO Insight
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

PropertySelection and IPropertySelectionModel in Apache Tapestry
By: Alexander Kolesnikov
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 18
    2007-06-12

    Table of Contents:
  • PropertySelection and IPropertySelectionModel in Apache Tapestry
  • Configuring PropertySelection
  • Working on the Model
  • One More Detail
  • So what have we done?

  • 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

    The Web Buyer's Guide is your best source for white papers on a wide range of IT products and services. This Week's Featured White Papers: Protecting Web Applications from Attack and Misuse by Citrix Systems

    PropertySelection and IPropertySelectionModel in Apache Tapestry - One More Detail
    (Page 4 of 5 )

    Is everything ready now? Not yet. Try to run the application, and when the Home page appears for the first time, you will see something that is not very nice:

    AS soon as the application started, the Home page requested an instance of the Celebrity class to be injected into it as a celebrityOfTheWeek ASO. Tapestry created such an instance and gave it to the Home page. However, this instance is empty; all its properties, including firstName and lastName have their default values, null. Hence the result.

    What we actually want is to show the celebrity of the week only if it was already chosen. This sounds like we need an If component. But what will be the criterion of whether the ASO was filled in with proper values or not? Let's say the first name should have some value stored in it. All we need to do is surround the fragment of the Home.html template displaying the celebrity of the week with an If component, like so:

    <div jwcid="@If" condition="ognl:theCelebrity.firstName != null">

      <p><strong>Celebrity of the Week</strong>:

        <span jwcid="celebrityOfTheWeek">John Smith</span></p>

    </div>

    Note that I am intentionally mixing together implicit and declared components. This might be not the best approach in a real life application, but here it gives me an opportunity to show you both ways. Also, you have a chance to develop a feeling for where your personal threshold between implicit and declared components lies.

    If you run the application now, it should work properly. When the Home page is displayed for the first time, it has no information about the Celebrity of the Week on it. Go to the list of Celebrities, grab the glorious title attached to one of them, and you'll see his or her name appearing on the Home page.

    If you now navigate to the CelebritiesList page again, you'll see that the celebrity you've just selected appears as a default choice in the drop-down list. This means that the connection between the PropertySelection component on the page and an ASO in the session on the server remains active.

    More Apache Articles
    More By Alexander Kolesnikov


       · PropertySelection is a very often used component, and it is important to learn how...
       · Hello:)is it possible to internationalize the values of the PropertySelection?
       · Yes, there are a few ways how you can do that, depending on the task at hand. I was...
       · Thanks :)I'm looking forward to the issue 14. :)
       · May be I missed something, but it seems there is a small issue with the sample you...
       · Well, I understand why you are asking this. Let's look at the whole code of the...
       · Somehow, the closing bracket of the annotation has turned into a winking smiley, but...
       · Hi, great tutorial at all, I'm also looking forward to article 14. Worked this...
     

       

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