org.apache.pluto.portlet.admin.taglib
Class MessageTag

java.lang.Object
  extended by javax.servlet.jsp.tagext.TagSupport
      extended by org.apache.pluto.portlet.admin.taglib.MessageTag
All Implemented Interfaces:
java.io.Serializable, javax.servlet.jsp.tagext.IterationTag, javax.servlet.jsp.tagext.Tag

public class MessageTag
extends javax.servlet.jsp.tagext.TagSupport

Tag to print an error, info, alert, status or success message in a portlet as defined by Cascading Syle Sheet classes in Appendix PLT C of the Java Portlet Specification (JSR-168) version 1.0 (pg 116).

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.

Author:
Craig Doremus
See Also:
PortletMessage, PortletMessageType, PlutoAdminConstants, Serialized Form

Field Summary
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.
 
Fields inherited from class javax.servlet.jsp.tagext.TagSupport
id, pageContext
 
Fields inherited from interface javax.servlet.jsp.tagext.IterationTag
EVAL_BODY_AGAIN
 
Fields inherited from interface javax.servlet.jsp.tagext.Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
 
Constructor Summary
MessageTag()
           
 
Method Summary
 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)
           
 
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
doAfterBody, doEndTag, findAncestorWithClass, getId, getParent, getValue, getValues, release, removeValue, setId, setPageContext, setParent, setValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MSG_ERROR_CSS_CLASS

public static final java.lang.String MSG_ERROR_CSS_CLASS
CSS class for Error messages. Example: Portlet not available

See Also:
Constant Field Values

MSG_INFO_CSS_CLASS

public static final java.lang.String MSG_INFO_CSS_CLASS
CSS class for Help messages, general additional information, etc. Example: Info about

See Also:
Constant Field Values

MSG_STATUS_CSS_CLASS

public static final java.lang.String MSG_STATUS_CSS_CLASS
CSS class for Status of the current operation. Example: Progress: 80%

See Also:
Constant Field Values

MSG_ALERT_CSS_CLASS

public static final java.lang.String MSG_ALERT_CSS_CLASS
CSS class for Warning messages. Example: Timeout occurred, try again later

See Also:
Constant Field Values

MSG_SUCCESS_CSS_CLASS

public static final java.lang.String MSG_SUCCESS_CSS_CLASS
CSS class for Verification of the successful completion of a task. Example: Operation completed successfully

See Also:
Constant Field Values
Constructor Detail

MessageTag

public MessageTag()
Method Detail

doStartTag

public int doStartTag()
               throws javax.servlet.jsp.JspException
Does the work of the tag.

Specified by:
doStartTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doStartTag in class javax.servlet.jsp.tagext.TagSupport
Throws:
javax.servlet.jsp.JspException

setMessage

public void setMessage(java.lang.String message)
Parameters:
message - The error message

setCssClass

public void setCssClass(java.lang.String cssClass)
Parameters:
cssClass - The cssClass to set.

setMessageType

public void setMessageType(java.lang.String messageType)
Parameters:
messageType - The messageType to set.


Copyright © 2003-2010 . All Rights Reserved.