I am going to show an example of how to create a tapestry5 Project to manage employee master details using Grid and beanEditForm Component. The database we are using is postgres. We are using Hibernate to connect to database.
Edit Employee Detail
Setup an empty maven project for eclipse. Once the project is imported to eclipse, create an empty project with org.my.in.sample as project namespace.
Open sample.pom and copy and paste the below code. We need to configure the dependencies
Create a new xml file hibernate.cfg.xml file. In this file we are going to configure for hibernate for postgres database. We are using a local database here
Create a new file sample.hbm.xml and define the entities as shown below. There are 2 entities we are going to use. one is for showing and another is for CRUD Operations.
First we are going to create an entity to view the list of employees.. Create a namespace org.my.in.entities in src/main/java. create a class EmployeeMasterListVO under it with the below code. Marking an object as @Nonvisual will hide it in the page.
Now we are going to create an entity for create, update, delete operations for employees.. Create a class EmployeeMasterEntityEO with the below code.
Page - EmployeeMasterPG
Employee Master Page. In package org.my.in.sample under src/main/resources create a page EmployeeMasterPG.tml. This is the page where we will be showing Employee master details. Copy and paste the contents of below into the page .
If you notice we are creating a grid to show the results using the Grid Component
Java - EmployeeMasterPG.java
Create a new java file in src/main/java folder inside namespace org.my.in.sample.pages
Create a namespace org.my.in.sample.model in src/main/java folder. Inside it create a class file named EmployeeMasterAM.java with the below code
Template - CreateEmployeeMasterPG.tml
Now we have created page to list the Employees. Now we will create a page to edit the employees and update it. Page - CreateEmployeeMasterPG.tml
Now we will create a java page for the same in org.my.in.sample.pages namespace under src/main/resources
Now we will create model page CreateEmployeeMasterAM.java under org.my.in.sample.model