Version 4.10.0

hirondelle.web4j.ui.translate
Class Messages

Object
  extended by SimpleTagSupport
      extended by hirondelle.web4j.ui.tag.TagHelper
          extended by hirondelle.web4j.ui.translate.Messages
All Implemented Interfaces:
JspTag, SimpleTag

public final class Messages
extends TagHelper

Custom tag for rendering a MessageList.

Example use case :

 <c:if test="${not empty web4j_key_for_messages}"> 
  Message(s) :
  <w:messages name="web4j_key_for_messages">
   <span class="message">placeholder</span><br>
  </w:messages>
  <c:remove var="web4j_key_for_messages" scope="session"/>
 </c:if>
 

The body of this tag is a simple template for emitting each element of the named MessageList. The special placeholder text is the location where each item returned by MessageList.getMessages() is displayed.


Field Summary
static String PLACEHOLDER
          Special text used by this class to conveniently identify where message text is placed.
 
Constructor Summary
Messages()
           
 
Method Summary
protected  String getEmittedText(String aOriginalBody)
          Emit given template text for each item in the MessageList.
 void setName(String aMessageListName)
          Key for a MessageList (in any scope).
 
Methods inherited from class hirondelle.web4j.ui.tag.TagHelper
checkForContent, crossCheckAttributes, doTag, getPageContext, getPageName, getRequest, getResponse
 
Methods inherited from class SimpleTagSupport
findAncestorWithClass, getJspBody, getJspContext, getParent, setJspBody, setJspContext, setParent
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PLACEHOLDER

public static final String PLACEHOLDER
Special text used by this class to conveniently identify where message text is placed.

See Also:
Constant Field Values
Constructor Detail

Messages

public Messages()
Method Detail

setName

public void setName(String aMessageListName)
Key for a MessageList (in any scope).

Required attribute. The ActionImpl class creates two such items, identified with ActionImpl.ERRORS and ActionImpl.MESSAGES.


getEmittedText

protected String getEmittedText(String aOriginalBody)
Emit given template text for each item in the MessageList.

Emit the text in this tag's body (which acts as a template), by replacing the special PLACEHOLDER text with the content of each message. The configured implementations of both LocaleSource and Translator are used to render each item. (This performs "last-second localization".)

Specified by:
getEmittedText in class TagHelper
Parameters:
aOriginalBody - is the evaluated body of this tag. If there is no body, or if the body is present but empty, then it is null.
Returns:
the text to display in the resulting web page.

Version 4.10.0

Copyright Hirondelle Systems. Published October 19, 2013 - User Guide - All Docs.