Home arrow Apache arrow Apache Tapestry and Listener Methods, Conditional Components and PageLink

Apache Tapestry and Listener Methods, Conditional Components and PageLink

Today we continue to explore some of the most fundamental concepts of Tapestry while building one of the simplest Java Web applications. In the previous part of this tutorial we became familiar with properties of Tapestry pages and different ways to configure them. Now we’ll look into the details of writing listener methods.

TABLE OF CONTENTS:
  1. Apache Tapestry and Listener Methods, Conditional Components and PageLink
  2. Passing information to the next page
  3. Conditional components
  4. PageLink component
  5. Deploying the application
By: Alexander Kolesnikov
Rating: starstarstarstarstar / 26
May 08, 2007

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

A downloadable zip file is available for this article.

The simplest approach

We have already used one listener method in our GuessTheWord application. Let’s remind ourselves how we did that.

In the Home.html template we created a form:

<form action="" jwcid="secretWordForm">

… some content …

</form>

Then in the Home.page specification we told Tapestry what to do when the form is submitted:

<component id="secretWordForm" type="Form">

   <binding name="listener" value="listener:onWordSubmit"/>

</component>

Which basically means that we want the onWordSubmit() listener method of the Home class to be invoked. And here is the method itself:

public String onWordSubmit() {

       return "Secret";

}

Right now, the listener method is very simple. It does not perform any processing and simply returns a String. Tapestry understands this as “Show the page with this name, please!” and displays the Secret page.

But the listener method could be even simpler than this, for example:

public void onWordSubmit() {

   // Do something

}

This version returns nothing – so the same page will be redisplayed. But if we put some code inside of the method, it will be executed, of course.

More often however we want some other page to be shown, and not only that, but we want to somehow prepare the next page before showing 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: