public class MessageTag
extends javax.servlet.jsp.tagext.TagSupport
This class uses the PortletMessage and PortletMessageType classes to encapsulates message information. It also can handle a Throwable put in the session (see below), using the getMessage() for the message and printing out the stack trace in an HTML comment. All messages are wrapped in a <p> element containing a 'class' attribute with a spec-defined CSS value, which assumes these are defined in a CSS style sheet used by the JSP page. Right now this class can only handle one message per JSP page.
There are three ways a message can be displayed using this tag:
1. Use the tag's message attribute on the JSP page to set the message
as a String or expression that evaluates to a String. Optionally, you
can use the messageType attribute. Valid messageType attributes
are info, error, status, success and alert. The default message
type is status.
2. Put a message in the portlet session encapsulated in a PortletMessage
object with a PlutoAdminConstants.MESSAGE_ATTR session key. This class
takes care of getting the attribute from the session, using its message and
type data and removing the session attribute.
3. Put a Throwable in the portlet session with a PlutoAdminConstants.ERROR_ATTR
key. This class takes care of getting the attribute from the session,
using its data and removing the session attribute. Throwables are always
given a messageType of error.
PortletMessage
,
PortletMessageType
,
PlutoAdminConstants
,
Serialized FormModifier and Type | Field and Description |
---|---|
static java.lang.String |
MSG_ALERT_CSS_CLASS
CSS class for Warning messages.
|
static java.lang.String |
MSG_ERROR_CSS_CLASS
CSS class for Error messages.
|
static java.lang.String |
MSG_INFO_CSS_CLASS
CSS class for Help messages, general additional information, etc.
|
static java.lang.String |
MSG_STATUS_CSS_CLASS
CSS class for Status of the current operation.
|
static java.lang.String |
MSG_SUCCESS_CSS_CLASS
CSS class for Verification of the successful completion of a task.
|
Constructor and Description |
---|
MessageTag() |
Modifier and Type | Method and Description |
---|---|
int |
doStartTag()
Does the work of the tag.
|
void |
setCssClass(java.lang.String cssClass) |
void |
setMessage(java.lang.String message) |
void |
setMessageType(java.lang.String messageType) |
public static final java.lang.String MSG_ERROR_CSS_CLASS
public static final java.lang.String MSG_INFO_CSS_CLASS
public static final java.lang.String MSG_STATUS_CSS_CLASS
public static final java.lang.String MSG_ALERT_CSS_CLASS
public static final java.lang.String MSG_SUCCESS_CSS_CLASS
public int doStartTag() throws javax.servlet.jsp.JspException
doStartTag
in interface javax.servlet.jsp.tagext.Tag
doStartTag
in class javax.servlet.jsp.tagext.TagSupport
javax.servlet.jsp.JspException
public void setMessage(java.lang.String message)
message
- The error messagepublic void setCssClass(java.lang.String cssClass)
cssClass
- The cssClass to set.public void setMessageType(java.lang.String messageType)
messageType
- The messageType to set.Copyright © 2003-2013 . All Rights Reserved.