Apache
  Home arrow Apache arrow Page 5 - The Properties of Tapestry Pages
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
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

The Properties of Tapestry Pages
By: Alexander Kolesnikov
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 24
    2007-05-07


    Table of Contents:
  • The Properties of Tapestry Pages
  • Different ways to manage page properties
  • Resetting page properties by hand
  • Configuring a property in page specification
  • Setting an initial value

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log 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 Properties of Tapestry Pages - Setting an initial value
    ( Page 5 of 5 )

    Let’s experiment with our current project. First of all, comment out the hidden binding of the secretWord component, so that we are able to see the initial value, perhaps like this:

    <component id="secretWord" type="TextField">

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

        <!--binding name="hidden" value="true"/-->

    </component>

    If you made any changes to how theWord property is configured, please revert now to the most convenient (and most often used) approach, an abstract getter. Now, if we want to give this property an initial value, we can use a relatively new feature of Java – an annotation. The result will look like this:

    @InitialValue("literal:enter a word")

    public abstract String getTheWord();

    Simple and elegant, isn’t it? Run the project, and you should see something similar to the following screen shot:

     

    Note that by default, the value inside of the double quotes inside the annotation is an OGNL expression. This means you can have a method providing an initial value for your property. Try something like this:

    @InitialValue("initialValue")

    public abstract String getTheWord();

       

    public String getInitialValue() {

        return "enter a word";

    }

    Run the project, and it should work exactly as it did before.

    But what if we wanted to configure this property in the page specification only? Let’s try this. Comment out the above abstract getter, its annotation and the getInitialValue() method (if you created it). Instead, add the following line of XML to the Home page specification:

    <property name="theWord" initial-value="literal:enter a word"/>

    Again, run the project, and it should work exactly as before.

    Finally, if you had to configure a property by hand, here is one possible approach to assigning it an initial value:

    public String getTheWord() {

       

        if (theWord == null) theWord = “enter a word";

      

        return theWord;

    }

     

    However, the more fundamental way to initialize a property is to override the finishLoad() method of the BasePage class:

    protected void finishLoad() {

        theWord = “enter a word";

    }

    This method will be invoked only once, when the page is loaded for the first time.

    All right, this seems to be everything I wanted to tell you about the properties of Tapestry pages for now. We have made some changes to the GuessTHeWord project, but that was for learning purposes only. You might want to revert the code to its initial state, undoing any changes we have made in this part of tutorial.

    What comes next

    In the next part, we are going to take a more detailed look at listener methods. They can be written in a few different ways and we are going to decide when each of the approaches can be useful for us, thus gradually expanding our Tapestry toolbox.

    If the space will allow, we might also try different ways of submitting a form, but on the other hand, this might be delayed until a later part.

    See you in a week.



     
     
    >>> More Apache Articles          >>> More By Alexander Kolesnikov
     

       

    APACHE ARTICLES

    - Creating a VAMP (Vista, Apache, MySQL, PHP) ...
    - 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...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    Stay green...Green IT