The execute method always gets the books list and adds it to the form so that additions and deletions are displayed immediately.
It also calls one of two business methods, insert or delete, depending on the function requested.
Let's code these methods that call the Session Bean business methods:

You see in the add method we use the BeanUtils.copyProperties method from Struts.
This utility sets the default id value to zero.
We need to change this to null. If we don't, the server will believe the entity to be attached to an id and will throw an error when we try to insert it.
See what I did here
|