Version 4.10.0

hirondelle.web4j.ui.translate
Class Tooltips

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

public final class Tooltips
extends TagHelper

Custom tag for translating TITLE, ALT and submit-button VALUE attributes in markup.

By using this custom tag once in a template JSP, it is often possible to translate all of the TITLE, ALT, and submit-button VALUE attributes appearing in an entire application.

The VALUE attribute is translated only for SUBMIT controls. (This VALUE attribute isn't really a tooltip, of course : it is rendered as the button text. For this custom tag, the distinction is not very important.)

The TITLE attribute applies to a large number of HTML tags, and the ALT attribute applies to several tags. In both cases, these items generate pop-up "tool tips", which are visible to the end user. If the application is multilingual, then they require translation.

This custom tag accepts HTML markup for its body, and will do a search and replace on its content, replacing the values of all TITLE, ALT and submit-button VALUE attributes (that have visible content) with translated values. The translations are provided by the configured implementations of Translator and LocaleSource.


Constructor Summary
Tooltips()
           
 
Method Summary
protected  String getEmittedText(String aOriginalBody)
          Scan the body of this tag, and translate the values of all TITLE, ALT, and submit-button VALUE attributes.
 void setEscapeChars(boolean aValue)
          Control the escaping of special characters.
 
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
 

Constructor Detail

Tooltips

public Tooltips()
Method Detail

setEscapeChars

public void setEscapeChars(boolean aValue)
Control the escaping of special characters.

By default, this tag will escape any special characters appearing in the TITLE or ALT attribute, using EscapeChars.forHTML(String). To override this default behaviour, set this value to false.


getEmittedText

protected String getEmittedText(String aOriginalBody)
Scan the body of this tag, and translate the values of all TITLE, ALT, and submit-button VALUE attributes.

Uses the configured Translator and LocaleSource.

In addition, this method uses EscapeChars.forHTML(String) to ensure that any special characters are escaped. This behavior can be overridden using setEscapeChars(boolean).

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.