...
Code Block | ||||
---|---|---|---|---|
| ||||
<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 | ||||
---|---|---|---|---|
| ||||
<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 | ||||
---|---|---|---|---|
| ||||
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.
...