Apache
  Home arrow Apache arrow Page 2 - Apache Tapestry: ASO and More Componen...
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

Apache Tapestry: ASO and More Components
By: Alexander Kolesnikov
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 12
    2007-05-21

    Table of Contents:
  • Apache Tapestry: ASO and More Components
  • Creating hivemodule.xml
  • AddCelebrity page
  • Creating the template with new components
  • Continuing to configure the application

  • 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

    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: ASO and More Components - Creating hivemodule.xml
    (Page 2 of 5 )

    Under WEB-INF folder, we need to create a new XML file named hivemodule.xml. Right-click WEB-INF in the Projects view, select New > File/Folder..., then select 'XML' in Categories and 'XML' for file types. Enter 'hivemodule' as the file name on the next page of the wizard; leave the selected 'Well-formed Document' for Document Type.

    Now change the contents of the new file to look like this:

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

     

    <module id="com.devshed.tapestry.celebrities" version="1.0.0">

      <contribution

           configuration-id="tapestry.state.ApplicationObjects">

        <state-object name="dataSource" scope="session">

          <create-instance

                    class="com.devshed.tapestry.celebrities.DataSource"/>

        </state-object>

      </contribution>

    </module>

    Let's see what we have here. The <module> element is the root of hivemodule.xml; we shall have it in every file like this. Note that the version attribute should look exactly as shown, i.e. it must contain three numbers separated by periods, or the application won't start.

    The <contribution> element tells HiveMind that we are going to contribute something of our own to its already existing extensive list of services and objects. The  tapestry.state.ApplicationObjects value for configuration ID explains what we are going to do with this object; it indicates an ASO.

    The <state-object> element gives the ASO its name under which we shall be requesting it in the pages. Also we have specified that the scope for this ASO is session. Session is basically a piece of memory associated specifically with the given user; nobody else can access this memory. So in our case there will be a separate instance of DataSource for each user, which makes sense to me, as different collectors will have different collections.

    Alternatively, we could use an application scope, and in that case all the users would share the same DataSource.

    Finally, the <create-instance> element specifies which class to instantiate to create the desired ASO.

    Now that we made available the DataSource as an Application State Object, we don't need to store its instance in the CelebritiesList page class. Remove the line of code where we've instantiated it before:

    private DataSource dataSource = new DataSource();

    And replace it with the following code:

    @InjectState("dataSource")

    public abstract DataSource getDataSource();

    These two lines of code can be used in any page and any component of the application to obtain a reference to the DataSource. All that remains now is to replace all the references to the removed dataSource property with invocations of the newly created method. Here is the completed code for the DependenciesList class:

    public abstract class CelebritiesList extends BasePage {

       

        @InjectState("dataSource")

        public abstract DataSource getDataSource();

       

        @InjectPage("Details")

        public abstract Details getDetailsPage();

       

        public List getCelebrities() {

            return getDataSource().getCelebrities();

        }

       

        public IPage onShowDetails(int id) {

           

            Celebrity celebrity = getDataSource().getCelebrityById(id);

     

            Details nextPage = getDetailsPage();

            nextPage.setCelebrity(celebrity);

           

            return nextPage;

        }

    }

    Now it is the time to create a page for creating a new Celebrity.

    More Apache Articles
    More By Alexander Kolesnikov


       · i have not so much experience with tapestry but i love it more than anything else. ...
       · Application State Objects are very useful in any Tapestry application. This issue...
       · Thank you very much! I am writing an issue on AJAX components by the way, and I am...
       · I have completed all this series of Tapestry tutorial in just two days and now I...
       · Thats great, but the tutorial is very far from completion :)The most interesting...
       · you mean issue 14 is online??? it is super! wow!!! but i didn found it:)I'm fan...
       · No, this means I have submitted it to the publisher :)It takes some time to edit...
       · :( I'm risking to ask you about new components. May I?Is it possible in an...
       · I am not sure what you want to achieve, but one solution would be to have a method...
       · Sorry, but DevShed delays the publication of the four issues I have already...
       · OK, so i have another error and i just can not figure it out. it says:"Unable to...
       · OK, I figured it out. The source read .Home instead of .AddCelebrity. Sometimes,...
       · Hi! Is there an alternative to using @InjectState? just like instead of @InjectPage,...
     

       

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