net.sourceforge.stripes.tag
Class MessagesTag

java.lang.Object
  extended by net.sourceforge.stripes.tag.StripesTagSupport
      extended by net.sourceforge.stripes.tag.HtmlTagSupport
          extended by net.sourceforge.stripes.tag.MessagesTag
All Implemented Interfaces:
DynamicAttributes, JspTag, Tag

public class MessagesTag
extends HtmlTagSupport

Displays a list of non-error messages to the user. The list of messages can come from either the request (preferred) or the session (checked 2nd). Lists of messages can be stored under any arbitrary key in request or session and the key can be specified to the messages tag. If no key is specified then the default key (and therefore default set of messages) is used. Note that by default the ActionBeanContext stores messages in a FlashScope which causes them to be exposed as request attributes in both the current and subsequent request (assuming a redirect is used).

While similar in concept to the ErrorsTag, the MessagesTag is significantly simpler. It deals with a List of Message objects, and does not understand any association between messages and form fields, or even between messages and forms. It is designed to be used to show arbitrary messages to the user, the prime example being a confirmation message displayed on the subsequent page following an action.

The messages tag outputs a header before the messages, the messages themselves, and a footer after the messages. Default values are set for each of these four items. Different values can be specified in the error messages resource bundle (StripesResources.properties unless you have configured another). The default configuration would look like this:

It should also be noted that while the errors tag supports custom headers and footers through the use of nested tags, the messages tag does not support this. In fact the messages tag does not support body content at all - it will simply be ignored.

Since:
Stripes 1.1.2
Author:
Tim Fennell

Field Summary
static String DEFAULT_FOOTER
          The footer that will be emitted if no footer is defined in the resource bundle.
static String DEFAULT_HEADER
          The header that will be emitted if no header is defined in the resource bundle.
 
Fields inherited from class net.sourceforge.stripes.tag.StripesTagSupport
pageContext, parentTag
 
Fields inherited from interface javax.servlet.jsp.tagext.Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
 
Constructor Summary
MessagesTag()
           
 
Method Summary
 int doEndTag()
          Outputs the set of messages appropriate for this tag.
 int doStartTag()
          Does nothing, all processing is performed in doEndTag().
 String getKey()
          Gets the key that will be used to scope search for messages to display.
protected  List<Message> getMessages()
          Gets the list of messages that will be displayed by the tag.
 void setKey(String key)
          Sets the key that will be used to scope search for messages to display.
 
Methods inherited from class net.sourceforge.stripes.tag.HtmlTagSupport
evaluateExpression, get, getAccesskey, getAttributes, getBodyContent, getBodyContentAsString, getCssClass, getDir, getId, getLang, getOnblur, getOnchange, getOnclick, getOndblclick, getOnfocus, getOnkeydown, getOnkeypress, getOnkeyup, getOnmousedown, getOnmousemove, getOnmouseout, getOnmouseover, getOnmouseup, getOnselect, getStyle, getTabindex, getTitle, release, set, setAccesskey, setBodyContent, setClass, setCssClass, setDir, setDynamicAttribute, setId, setLang, setOnblur, setOnchange, setOnclick, setOndblclick, setOnfocus, setOnkeydown, setOnkeypress, setOnkeyup, setOnmousedown, setOnmousemove, setOnmouseout, setOnmouseover, setOnmouseup, setOnselect, setStyle, setTabindex, setTitle, toString, writeAttributes, writeCloseTag, writeOpenTag, writeSingletonTag
 
Methods inherited from class net.sourceforge.stripes.tag.StripesTagSupport
getActionBeanType, getActionBeanUrl, getPageContext, getParent, getParentTag, getTagStack, popPageContextAttributes, pushPageContextAttributes, setPageContext, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_HEADER

public static final String DEFAULT_HEADER
The header that will be emitted if no header is defined in the resource bundle.

See Also:
Constant Field Values

DEFAULT_FOOTER

public static final String DEFAULT_FOOTER
The footer that will be emitted if no footer is defined in the resource bundle.

See Also:
Constant Field Values
Constructor Detail

MessagesTag

public MessagesTag()
Method Detail

doStartTag

public int doStartTag()
               throws JspException
Does nothing, all processing is performed in doEndTag().

Specified by:
doStartTag in interface Tag
Specified by:
doStartTag in class StripesTagSupport
Returns:
SKIP_BODY in all cases.
Throws:
JspException

doEndTag

public int doEndTag()
             throws JspException
Outputs the set of messages appropriate for this tag.

Specified by:
doEndTag in interface Tag
Specified by:
doEndTag in class StripesTagSupport
Returns:
EVAL_PAGE always
Throws:
JspException

getKey

public String getKey()
Gets the key that will be used to scope search for messages to display.


setKey

public void setKey(String key)
Sets the key that will be used to scope search for messages to display.


getMessages

protected List<Message> getMessages()
Gets the list of messages that will be displayed by the tag. Looks first in the request under the specified key, and if none are found, then looks in session under the same key.

Returns:
List a possibly null list of messages to display


? Copyright 2005-2006, Stripes Development Team.