Hello Visitor
In previous posts we created base project and added common layout to ItemDirectory Wicket application. Today we are going to add first form to allow users to insert some data into our application.
As main feature of ItemDirectory is to manage information where items (books, movies, music, postage stamps) are stored in our home/work, the first data we need to know are locations where we actually can store those things. So we start with adding table, entity and form to manage locations of our precious items.
Database, entity and DAO
First thing we need is locations table in database and entity mapping class:
- sql create table script listing:
create table locations (
id bigint(20) not null auto_increment,
name varchar(255) not null,
PRIMARY KEY (id),
UNIQUE KEY unique_name (name)
);
- entity class listing:
@javax.persistence.Entity
@Table(name = "locations")
public class Location extends AbstractEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(length=255, nullable=false)
private String name;
protected Location() {
super();
}
public Location(String name) {
super();
this.name = name;
}
// getters, setters omitted
}
As you can see, Location class is very simple: only one field, but the only thing we want at the moment from this entity is a name describing where item is stored. Is it “Bookcase in living room, second drawer from the top” or “Cabinet in the saloon, top bookshelf”.


