com.taggercat.tags
Class DataFieldCaptionTag

java.lang.Object
  extended by javax.servlet.jsp.tagext.TagSupport
      extended by com.taggercat.tags.DataFieldCaptionTag
All Implemented Interfaces:
java.io.Serializable, javax.servlet.jsp.tagext.IterationTag, javax.servlet.jsp.tagext.JspTag, javax.servlet.jsp.tagext.Tag

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

This tag displays the caption of the named data field.

This tag has three roles.

  1. To read the field's caption from Tagger Cat's metadata, as compared to declaring it as static text on the JSP page. This enables field captions to change dynamically ( and in sync ) with updated captions in the metadata repository. Reading field captions from the metadata is only supported when internationalization is not enabled.
  2. To highlight the field's caption when data validation or other errors occur. For example, fields with invalid entry values can be shown in a bold red font.
  3. To internationalize the fields caption. To enable internationalization you must:
    Configure the context init parameter i18nFieldCaptions
    Set this parameter to true to enable internationalize for all Data Field Captions
    Add internationalized property files.
    The base resource bundle is named PropertyCaptions.properties
    Add property keys and values
    The property keys dot delimited Entity Short Name and the property name ex: Customer.name
Examples:
 <tc:fieldCaption dsn='customer' field='TERRITORY' default='Territory' />
 <tc:fieldCaption dsn='customer' field='TERRITORY' default='Territory' static='true' />
 

The default attribute is used when internationalization is not enabled and there no caption is set in the metadata , or if the static attribute is 'true'. If the static attribute is 'true', then the default attribute is always used, and there is no attempt to read the caption from the metadata.

Highlighting Error Fields

Field Captions can be highlighted in the event of validation and certain other types of errors.
To enable highlighting of the captions on error fields, a context-param named errorFieldFormat must be included in the application's deployment descriptor. The parameter value is used as a format string (usually a CSS class ) to embed the field's caption into.
It is important to note that this is a <context-param>, and NOT a <init-param> in the <servlet/> element. The format string must contain a single {0} placeholder for the field caption. Also note that any HTML within the param-value element must be escaped or inclosed in a CDATA section. Here is an example section of a web.xml file:

 <web-app>
 <display-name>Order Processing</display-name>
 
<context-param> <param-name>errorFieldFormat</param-name> <param-value><![CDATA[<span class="errorCaption">{0}</span>]]></param-value> </context-param>
<servlet> ...... </servlet>

See Also:
Serialized Form
 

Field Summary
 
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
DataFieldCaptionTag()
           
 
Method Summary
 int doEndTag()
          Resets the tags internal state.
 int doStartTag()
          Creates the field's caption.
 void setDefault(java.lang.String defaultCaption)
          Sets the default caption string, used when there is no caption.
 void setDefaultCaption(java.lang.String defaultCaption)
          Sets the default caption.
 void setDsn(java.lang.String dsn)
          Set the name of the data source this field is a member of.
 void setField(java.lang.String field)
          Sets the field name attribute.
 void setStatic(boolean isStatic)
          Sets the isStatic field.
 void setStatic(java.lang.String isStatic)
          Sets the static attribute,if set true, the "default" caption is always used for the caption.
 java.lang.String toString()
          Returns a string representation of this tag.
 
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
doAfterBody, findAncestorWithClass, getId, getParent, getValue, getValues, release, removeValue, setId, setPageContext, setParent, setValue
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DataFieldCaptionTag

public DataFieldCaptionTag()
Method Detail

doEndTag

public int doEndTag()
             throws javax.servlet.jsp.JspException
Resets the tags internal state.

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

doStartTag

public int doStartTag()
               throws javax.servlet.jsp.JspException
Creates the field's caption.

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

setDefault

public void setDefault(java.lang.String defaultCaption)
Sets the default caption string, used when there is no caption.

Parameters:
defaultCaption - the new default caption value

setDsn

public void setDsn(java.lang.String dsn)
Set the name of the data source this field is a member of.

Parameters:
dsn - the data source name

setField

public void setField(java.lang.String field)
Sets the field name attribute.

Parameters:
field - the new field value

setStatic

public void setStatic(java.lang.String isStatic)
Sets the static attribute,if set true, the "default" caption is always used for the caption.

Parameters:
isStatic - the isStatic value

toString

public java.lang.String toString()
Returns a string representation of this tag.

Overrides:
toString in class java.lang.Object
Returns:
a listing of the current attributes

setDefaultCaption

public void setDefaultCaption(java.lang.String defaultCaption)
Sets the default caption.

Parameters:
defaultCaption - the default caption

setStatic

public void setStatic(boolean isStatic)
Sets the isStatic field.

Parameters:
isStatic - the isStatic field