Java Reference
In-Depth Information
Figure 3.8: Dialog box to confirm before delete
Information Messages
OK, so we've added a message before deleting a contact. It'd be nice to
also add a message after deleting to inform the user that the operation
was successful.
Stripes provides a simple mechanism for displaying information mes-
sages. It is a two-step process:
1. Add messages to the action bean context.
2. Display them in the view.
Adding Messages to the Context
The
ActionBeanContext
contains a list of information messages. We can
retrieve the list via
getMessages
( ) and add messages with
add(Message)
.
Here's how we add a message to confirm that a contact was deleted:
public
Resolution delete() {
Contact deleted = contactDao.read(contactId);
contactDao.delete(contactId);
getContext().getMessages().add(
new
SimpleMessage("Deleted {0}.", deleted)
);
return new
RedirectResolution(getClass());
}
Search WWH ::
Custom Search