Class SetContentBundleTag

  • All Implemented Interfaces:
    java.io.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 Resource does not contain a certain key.

    The language/locale of the CQ resource bundle is determined depending on the "source" attribute, which can be either

    • static use "language" attribute,
    • request uses request.getLocale(),
    • page uses language of the current page or resource or
    • auto page if available, otherwise use locale from request.
    Defaults to "auto" or "static", if "language" is set. For "page" the "language" attribute will be used as fallback, if given. If the "language" attribute is not set, but expected, the server default locale will be used.
    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
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int doEndTag()
      Sets a default LocalizationContext in Config with a page scope.
      java.lang.String getBasename()  
      java.lang.String getLanguage()  
      java.lang.String getSource()  
      void setBasename​(java.lang.String basename)  
      void setLanguage​(java.lang.String language)  
      void setSource​(java.lang.String source)  
      • 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

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SetContentBundleTag

        public SetContentBundleTag()
    • Method Detail

      • doEndTag

        public int doEndTag()
        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.
      • setSource

        public void setSource​(java.lang.String source)
                       throws javax.servlet.jsp.JspException
        Throws:
        javax.servlet.jsp.JspException
      • getSource

        public java.lang.String getSource()
      • getLanguage

        public java.lang.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​(java.lang.String language)
        Parameters:
        language - the language that will be used when a resource bundle is obtained.
      • getBasename

        public java.lang.String getBasename()
        Returns:
        the currently set basename that should be used or null.
      • setBasename

        public void setBasename​(java.lang.String basename)
        Parameters:
        basename - the basename that will be used when a resource bundle is obtained.