Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: More tutorial updates to the last page

...

Code Block
languagexml
titlesrc/pom.xml (partial)
    <dependencies>

        <dependency>
            <groupId>org.apache.tapestry</groupId>
            <artifactId>tapestry-hibernate</artifactId>
            <version>${tapestry-release-version}</version>
        </dependency>

        <dependency>
            <groupId>org.hsqldb	<hsqldb</groupId>
            <artifactId>hsqldb</artifactId>
            <version>2.3.2</version>
        </dependency>
        ...
    </dependencies>

...

A minimal Grid is very easy to add to the template. Just add this near the bottom of Index.tml:

Code Block
languagexml
titlesrc/main/webapp/Index.tml (partial)
  <t:grid source="addresses"/>

And all we have to do is supply the addresses property in the Java code. Here's how Index.java should look now:

Code Block
languagejava
titlesrc/main/java/com/example/tutorial/pages/Index.java (partial)
package com.example.tutorial.pages;
import java.util.List;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.hibernate.Session;
import com.example.tutorial.entities.Address;
public class Index
{
    @Inject
    private Session session;

    public List<Address> getAddresses()
    {
        return session.createCriteria(Address.class).list();
    }
}

Here, we're using the Hibernate Session object to find all Address objects in the database. Any sorting that takes place will be done in memory. This is fine for now (with only a handful of Address objects in the database). Later we'll see how to optimize this for very large result sets.

...