Our user is able to create the contact details and she can now update the entries. To complete our customer's journey, we should allow her to remove the entries as a good Net citizen. Why there are so many companies out there that want to block the access to delete the user's data by putting in hazards or extra hassles to make such a simple task so difficult is beyond me! However, we can do this for our contact detail application and it is now straightforward as we have the building blocks in place.
We will add a removeDetail()
method to ContactDetailController
. Here is the extra method:
public class ContactDetailController { // ... as before ... public String removeContact() { contactDetail = contactDetailService.findById(id).get(0); contactDetailService.delete(contactDetail); contactDetail = new ContactDetail(); return "index.xhtml"; } }
This method searches for contactDetail
by a fresh id
. The id
field is the controller's property, which is set in a hidden...