|
Version 4.5.0
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface MessageList
List of AppResponseMessage objects to be shown to the user.
Used for error messages, success messages, or any such item communicated to the user. See displayMessages.tag in the example application for an illustration of rendering a MessageList.
If a message needs to survive a redirect, it must be placed in session scope, not request scope. Typically, successful edits to the database use a redirect (to avoid the duplicate-upon-browser-reload problem), so success messages will almost always be placed in session scope. Conversely, failure messages will usually be placed in request scope.
Design Note
The forces which WEB4J resolves are :
This item is provided as an interface because
AppException needs to be both an Exception
and a MessageList.
| Method Summary | |
|---|---|
void |
add(AppException aAppEx)
Add all AppResponseMessages attached to aAppEx to this list. |
void |
add(String aErrorMessage)
Add a simple AppResponseMessage to this list. |
void |
add(String aErrorMessage,
Object... aParams)
Add a compound AppResponseMessage to this list. |
boolean |
getIsDisplayable()
Return true only if messages exist and getMessagesForSingleDisplay()
has not yet been called. |
List<AppResponseMessage> |
getMessages()
Return an unmodifiable List of AppResponseMessages. |
List<AppResponseMessage> |
getMessagesForSingleDisplay()
Render the messages in a JSP. |
boolean |
isEmpty()
Return true only if there are no messages in this list. |
boolean |
isNotEmpty()
Return the negation of isEmpty(). |
| Method Detail |
|---|
void add(String aErrorMessage)
AppResponseMessage to this list.
The argument satisfies the same conditions as AppResponseMessage.forSimple(java.lang.String).
void add(String aErrorMessage,
Object... aParams)
AppResponseMessage to this list.
The arguments satisfy the same conditions as AppResponseMessage.forCompound(java.lang.String, java.lang.Object...).
void add(AppException aAppEx)
AppResponseMessages attached to aAppEx to this list.
boolean isEmpty()
Note that this method name conflicts with the empty keyword
of JSTL. Thus, isNotEmpty() is supplied as an alternative.
boolean isNotEmpty()
isEmpty().
boolean getIsDisplayable()
getMessagesForSingleDisplay()
has not yet been called.
List<AppResponseMessage> getMessages()
AppResponseMessages.
JSPs must call getMessagesForSingleDisplay() instead of this method.
List<AppResponseMessage> getMessagesForSingleDisplay()
JSPs must call this method when rendering messages.
This method solves the following problem. Some messages need to survive a redirect. This is implemented in WEB4J by placing the messages in session scope. However, the messages should be displayed to the user only once. So the problem arises of what to do with session-scope messages once they have been displayed.
Here, the technique used is to keep the object in session scope, but if the rendering task is performed a second time on the same messages (that is, if this method is called a second time on the same object), an empty List is returned, and no text will be rendered. This is an unusual policy for an object.
getMessages() - otherwise, return an empty List.
|
Version 4.5.0
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||