Apache
  Home arrow Apache arrow Page 2 - Apache Tapestry: ASO and More Components
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? 
Google.com  
APACHE

Apache Tapestry: ASO and More Components
By: Alexander Kolesnikov
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 17
    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:
      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


    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
     

       

    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 3 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek