com.day.cq.wcm.tags
Class SetContentBundleTag

java.lang.Object
  extended by javax.servlet.jsp.tagext.TagSupport
      extended by com.day.cq.wcm.tags.SetContentBundleTag
All Implemented Interfaces:
Serializable, javax.servlet.jsp.tagext.IterationTag, javax.servlet.jsp.tagext.JspTag, javax.servlet.jsp.tagext.Tag

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

SetContentBundleTag implements a custom tag, which sets a LocalizationContext backed with a ContentResourceBundle. This allows one to use property names as keys in a JSTL formatting action and use the value of the property as localized message.

The provided resource bundle also uses the resource bundle provided by CQ as a fallback if the underlying JCR node does not contain a certain key. The language/locale of the CQ resource bundle is derived from the request. One can overwrite this mechanism by explicitly setting a language using setLanguage(String).

See Also:
Serialized Form

Field Summary
 
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
SetContentBundleTag()
           
 
Method Summary
 int doEndTag()
          Sets a default LocalizationContext in Config with a page scope.
 String getLanguage()
           
 void setLanguage(String language)
           
 
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
doAfterBody, doStartTag, 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
 

Constructor Detail

SetContentBundleTag

public SetContentBundleTag()
Method Detail

doEndTag

public int doEndTag()
             throws javax.servlet.jsp.JspException
Sets a default LocalizationContext in Config with a page scope.

Specified by:
doEndTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doEndTag in class javax.servlet.jsp.tagext.TagSupport
Returns:
Tag.EVAL_PAGE.
Throws:
javax.servlet.jsp.JspException - if an error occurs while creating a content backed resource bundle.

getLanguage

public String getLanguage()
Returns:
the currently set language that should be used or null if the language should be derived from the path of the current resource.

setLanguage

public void setLanguage(String language)
Parameters:
language - the language that will be used when a resource bundle is obtained.


Copyright © 2009 Day Management AG. All Rights Reserved.