Home arrow Apache arrow Page 2 - PropertySelection and IPropertySelectionModel in Apache Tapestry

Configuring PropertySelection - Apache

We already encountered PropertySelection in one of the previous articles so we know that it is a Tapestry component used to display a drop-down list, allowing the user to choose one of multiple options. You might think that the way in which options are provided to this component (through its model binding) is somewhat cumbersome when all you need to do is select one of a few strings. However, PropertySelection was designed with a great deal of power and flexibility in mind, and I hope that today you will appreciate this.

TABLE OF CONTENTS:
  1. PropertySelection and IPropertySelectionModel in Apache Tapestry
  2. Configuring PropertySelection
  3. Working on the Model
  4. One More Detail
  5. So what have we done?
By: Alexander Kolesnikov
Rating: starstarstarstarstar / 24
June 12, 2007

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement
 

As you already know, the component used to do this kind of job in Tapestry is PropertySelection. Let's configure it in the CelebritiesList page. Here is the addition to the template:

<form action="" jwcid="@Form">

  <select jwcid="selectCelebrity">

    <option value="1">Angelina Jolie</option>

    <option value="2">Bill Gates</option>

  </select>

  <input type="submit" value="Save"/>

</form>

Let's add a property to store the selected celebrity in the page class. We want some other page to be able to display the selected celebrity afterward, so it will be an ASO:

@InjectState("celebrityOfTheWeek")

public abstract Celebrity getCelebrityOfTheWeek();

You already know how to configure an ASO in hivemodule.xml, but here is the addition, just to help you:

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

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

    <create-instance

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

  </state-object>

</contribution>

Finally, we need to configure the component in the page specification:

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

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

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

</component>

The last piece of configuration is to provide a model, which should be an implementation of the IPropertySelectionModel interface. We don't have a proper model yet, so let's just return a null:

public IPropertySelectionModel getCelebrityModel() {

  return null;

}

This will not work however as we need to return a real model. To summarize what we have already done, you can see that the PropertySelection component per se is quite simple, it doesn't take much effort to configure. It is the model that requires the most thought this collaboration, and we do need to write some code to implement it.



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

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

APACHE ARTICLES

- Apache Unveils Cassandra 1.2
- Apache on ARM Chips? Dell and Calxeda Help M...
- The Down Side of Open Source Software
- VMware Unveils Serengeti for Apache Hadoop
- SAP Takes Steps to Improve Hadoop Integration
- Looking to Hone Apache Hadoop Skills?
- How to Install Joomla on WAMPP
- Working with XAMPP and Wordpress
- GUI Available for Apache Camel
- Reduce Server Load for Apache and PHP Websit...
- Creating a VAMP (Vista, Apache, MySQL, PHP) ...
- Putting Apache in Jail
- Containing Intrusions in Apache
- Server Limits for Apache Security
- Setting Permissions in Apache

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: