Class WMessageBox
- java.lang.Object
-
- com.github.bordertech.wcomponents.AbstractWComponent
-
- com.github.bordertech.wcomponents.WMessageBox
-
- All Implemented Interfaces:
AjaxTarget,SubordinateTarget,WComponent,WebComponent,Serializable
public class WMessageBox extends AbstractWComponent implements AjaxTarget, SubordinateTarget
A
WMessageBoxis a component that renders a collection of informational messages. Most commonly placed near the top of an application's UI.The different message types catered for here are:
- Error - For reporting system and application errors.
- Warning - For warning users about the possible consequences of an action. The process may continue.
- Information - For providing general information.
- Success - For reporting on the success of an action or operation.
NOTE: Validation errors should be provided via the component
WValidationErrors.- Author:
- Ming Gao, Adam Millard, Jonathan Austin, Mark Reeves
- See Also:
WValidationErrors,WMessages, Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classWMessageBox.MessageModelHolds the extrinsic state information of a WMessageBox.static classWMessageBox.TypeAn enumeration of message box types.-
Nested classes/interfaces inherited from class com.github.bordertech.wcomponents.AbstractWComponent
AbstractWComponent.WComponentRef
-
-
Field Summary
Fields Modifier and Type Field Description static WMessageBox.TypeERRORThe message box type used to display error messages.static WMessageBox.TypeINFOThe message box type used to display informational messages.static WMessageBox.TypeSUCCESSThe message box type used to display "success" messages.static WMessageBox.TypeWARNThe message box type used to display warning messages.-
Fields inherited from interface com.github.bordertech.wcomponents.WComponent
DEFAULT_APPLICATION_ID, DEFAULT_INTERNAL_ID, DEFAULT_NO_ID, ID_CONTEXT_SEPERATOR, ID_FRAMEWORK_ASSIGNED_SEPERATOR, ID_VALIDATION_PATTERN
-
-
Constructor Summary
Constructors Constructor Description WMessageBox(WMessageBox.Type type)Creates a WMessageBox of the given type.WMessageBox(WMessageBox.Type type, boolean encode, String msg, Serializable... args)Creates a WMessageBox of the given type with an initial message.WMessageBox(WMessageBox.Type type, String msg, Serializable... args)Creates a WMessageBox of the given type with an initial message.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddMessage(boolean encode, String msg, Serializable... args)Adds a message to the message box.voidaddMessage(String msg, Serializable... args)Adds a message to the message box.voidclearMessages()Removes all messages from the message box.protected WMessageBox.MessageModelgetComponentModel()Returns the effective component model for this component.List<String>getMessages()Retrieves the list of messages.protected WMessageBox.MessageModelgetOrCreateComponentModel()Retrieves the model for this component so that it can be modified.StringgetTitleText()WMessageBox.TypegetType()booleanhasMessages()Indicates whether the message box contains messages in the given context.protected ComponentModelnewComponentModel()Creates a new component model appropriate for this component.voidremoveMessage(int index)Removes a message from the message box.voidremoveMessages(int index)Removes a message from the message box.voidsetTitleText(String title, Serializable... args)Sets the message box title.voidsetType(WMessageBox.Type type)Sets the message box type.StringtoString()Creates a String representation of this component; usually for debugging purposes.-
Methods inherited from class com.github.bordertech.wcomponents.AbstractWComponent
addHtmlClass, addHtmlClass, addNotify, afterPaint, assertAddSupported, beforePaint, createErrorDiagnostic, createErrorDiagnostic, forward, getAccessibleText, getAttribute, getBaseUrl, getDefaultModel, getEnvironment, getHeaders, getHtmlClass, getHtmlClasses, getId, getIdName, getInternalId, getLabel, getName, getParent, getScratchMap, getTabIndex, getTag, getTemplate, getTemplateMarkUp, getToolTip, handleRequest, hasNoComponentModel, hasTabIndex, initialiseComponentModel, invokeLater, invokeLaters, isDebugStructure, isDefaultState, isFlagSet, isHidden, isInitialised, isLocked, isTracking, isTrackingEnabled, isValidate, isVisible, paint, paintComponent, preparePaint, preparePaintComponent, removeAttribute, removeComponentModel, removeHtmlClass, removeHtmlClass, removeNotify, replaceWComponent, reset, serviceRequest, setAccessibleText, setAttribute, setEnvironment, setFlag, setFocussed, setHidden, setHtmlClass, setHtmlClass, setIdName, setInitialised, setLocked, setTag, setToolTip, setTrackingEnabled, setValidate, setVisible, showErrorIndicators, showErrorIndicatorsForComponent, showWarningIndicators, showWarningIndicatorsForComponent, tidyUpUIContext, tidyUpUIContextForTree, validate, validateComponent, writeReplace
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.github.bordertech.wcomponents.WComponent
addHtmlClass, addHtmlClass, forward, getAccessibleText, getAttribute, getBaseUrl, getEnvironment, getHeaders, getHtmlClass, getHtmlClasses, getId, getIdName, getInternalId, getLabel, getName, getParent, getTabIndex, getTag, getToolTip, handleRequest, hasTabIndex, invokeLater, isDefaultState, isHidden, isInitialised, isLocked, isTracking, isTrackingEnabled, isValidate, isVisible, paint, preparePaint, removeAttribute, removeHtmlClass, removeHtmlClass, reset, serviceRequest, setAccessibleText, setAttribute, setEnvironment, setFocussed, setHtmlClass, setHtmlClass, setIdName, setInitialised, setLocked, setTag, setToolTip, setTrackingEnabled, setValidate, setVisible, showErrorIndicators, showWarningIndicators, tidyUpUIContextForTree, validate
-
-
-
-
Field Detail
-
SUCCESS
public static final WMessageBox.Type SUCCESS
The message box type used to display "success" messages.
-
INFO
public static final WMessageBox.Type INFO
The message box type used to display informational messages.
-
WARN
public static final WMessageBox.Type WARN
The message box type used to display warning messages.
-
ERROR
public static final WMessageBox.Type ERROR
The message box type used to display error messages.
-
-
Constructor Detail
-
WMessageBox
public WMessageBox(WMessageBox.Type type)
Creates a WMessageBox of the given type.
-
WMessageBox
public WMessageBox(WMessageBox.Type type, String msg, Serializable... args)
Creates a WMessageBox of the given type with an initial message.- Parameters:
type- the messageBox type, one ofSUCCESS,INFO,WARNorERROR.msg- the initial message to display, usingMessageFormatsyntax.args- optional arguments for the message format string.
-
WMessageBox
public WMessageBox(WMessageBox.Type type, boolean encode, String msg, Serializable... args)
Creates a WMessageBox of the given type with an initial message.- Parameters:
type- the messageBox type, one ofSUCCESS,INFO,WARNorERROR.encode- true to encode the message text, false to leave it unencoded.msg- the initial message to display, usingMessageFormatsyntax.args- optional arguments for the message format string.
-
-
Method Detail
-
setType
public void setType(WMessageBox.Type type)
Sets the message box type.
-
getType
public WMessageBox.Type getType()
- Returns:
- the message box type for the given context.
-
setTitleText
public void setTitleText(String title, Serializable... args)
Sets the message box title.- Parameters:
title- the message box title to set, usingMessageFormatsyntax.args- optional arguments for the message format string.
-
getTitleText
public String getTitleText()
- Returns:
- the message box title.
-
addMessage
public void addMessage(String msg, Serializable... args)
Adds a message to the message box.- Parameters:
msg- the text of the message to add, usingMessageFormatsyntax.args- optional arguments for the message format string.
-
addMessage
public void addMessage(boolean encode, String msg, Serializable... args)Adds a message to the message box.- Parameters:
encode- true to encode the message text, false to leave it unencoded.msg- the text of the message to add, usingMessageFormatsyntax.args- optional arguments for the message format string.
-
removeMessage
public void removeMessage(int index)
Removes a message from the message box.- Parameters:
index- the index of the message to remove.
-
removeMessages
public void removeMessages(int index)
Removes a message from the message box.- Parameters:
index- the index of the mssage to remove.
-
clearMessages
public void clearMessages()
Removes all messages from the message box.
-
getMessages
public List<String> getMessages()
Retrieves the list of messages.- Returns:
- the messages for the current context.
-
hasMessages
public boolean hasMessages()
Indicates whether the message box contains messages in the given context.- Returns:
- true if the message box contains at least one message.
-
toString
public String toString()
Creates a String representation of this component; usually for debugging purposes.- Overrides:
toStringin classAbstractWComponent- Returns:
- a String representation of this component.
-
newComponentModel
protected ComponentModel newComponentModel()
Creates a new component model appropriate for this component.- Overrides:
newComponentModelin classAbstractWComponent- Returns:
- a new MessageModel.
-
getComponentModel
protected WMessageBox.MessageModel getComponentModel()
Returns the effective component model for this component. Subclass may override this method to narrow the return type to their specific model type.- Overrides:
getComponentModelin classAbstractWComponent- Returns:
- the effective component model
-
getOrCreateComponentModel
protected WMessageBox.MessageModel getOrCreateComponentModel()
Retrieves the model for this component so that it can be modified. If this method is called during request processing, and a session specific model does not yet exist, then a new model is created. Subclasses may override this method to narrow the return type to their specific model type.- Overrides:
getOrCreateComponentModelin classAbstractWComponent- Returns:
- the model for this component
-
-