org.opensubsystems.core.www
Class BlockElementTag

java.lang.Object
  extended by javax.servlet.jsp.tagext.TagSupport
      extended by javax.servlet.jsp.tagext.BodyTagSupport
          extended by org.opensubsystems.core.www.PageElementCacheTag
              extended by org.opensubsystems.core.www.BlockElementTag
All Implemented Interfaces:
java.io.Serializable, javax.servlet.jsp.tagext.BodyTag, javax.servlet.jsp.tagext.IterationTag, javax.servlet.jsp.tagext.JspTag, javax.servlet.jsp.tagext.Tag
Direct Known Subclasses:
WebModuleTag

public class BlockElementTag
extends PageElementCacheTag

Custom tag to generate all HTML code necessary to display block element (DIV or SPAN), for which we can set id and style and the ID is remembered so that child containers can access it and use it to generate compound IDs.

Version:
$Id: BlockElementTag.java,v 1.16 2007/01/07 06:14:08 bastafidli Exp $
Author:
Miro Halas
See Also:
Serialized Form
Code reviewer:
Miro Halas
Code reviewed:
1.12 2006/02/17 06:54:09 bastafidli

Field Summary
static java.lang.String CURRENT_ELEMENT_ID
          Name of the attribute representing stack storing ID of the current element.
static java.lang.String DIV_BLOCK_ELEMENT
          DIV block element.
protected  java.lang.String m_strCssclass
          Class for the the whole element.
protected  java.lang.String m_strIdSuffix
          Suffix to append to id when generating HTML.
protected  java.lang.String m_strRelatedIds
          Flag signaling if the id of this element is related to the id of the parent element.
protected  java.lang.String m_strStyle
          Additional CSS style for the the whole element.
protected  java.lang.String m_strType
          Type of the block element.
static java.lang.String SPAN_BLOCK_ELEMENT
          SPAN block element.
 
Fields inherited from class org.opensubsystems.core.www.PageElementCacheTag
CACHE_INDICATOR, CSS_ELEMENT, JS_ELEMENT, m_strCacheas, m_strId, PAGE_ELEMENTS_CACHE, SCRIPT_ELEMENT
 
Fields inherited from class javax.servlet.jsp.tagext.BodyTagSupport
bodyContent
 
Fields inherited from class javax.servlet.jsp.tagext.TagSupport
id, pageContext
 
Fields inherited from interface javax.servlet.jsp.tagext.BodyTag
EVAL_BODY_BUFFERED, EVAL_BODY_TAG
 
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
BlockElementTag(java.lang.String strCssclass, java.lang.String strType)
          Constructor for custom tag.
 
Method Summary
protected  void adjustId()
          Checks if the ids of this and parent tags are related and if they are, change the id of this tag to be concatenation with the parent id.
 int doEndTag()
          
 int doStartTag()
          
 java.lang.String getCssclass()
           
protected  java.lang.String getCurrentId()
          Restore to the current id to be used by nested elements.
 java.lang.String getRelatedids()
           
 java.lang.String getStyle()
           
 java.lang.String getType()
           
 boolean isRelatedIdsTag()
           
protected  void popCurrentId()
          Restore to the current id to be used by nested elements.
protected  void pushCurrentId()
          Store to the current id to be used by nested elements.
protected  void restoreId()
          Restore the changed (if any) made by adjustId method.
 void setCssclass(java.lang.String strCssclass)
           
 void setRelatedids(boolean bRelatedIds)
           
 void setRelatedids(java.lang.String strRelatedIds)
           
protected  void setStoredId(boolean bIdStored)
          Set up flag for stored ID
 void setStyle(java.lang.String style)
           
 void setType(java.lang.String strType)
           
 
Methods inherited from class org.opensubsystems.core.www.PageElementCacheTag
cache, getCacheas, getCachedContent, getCachedContent, getCachedContent, getCachedContentElements, getId, setCacheas, setId
 
Methods inherited from class javax.servlet.jsp.tagext.BodyTagSupport
doAfterBody, doInitBody, getBodyContent, getPreviousOut, release, setBodyContent
 
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
findAncestorWithClass, getParent, getValue, getValues, removeValue, setPageContext, setParent, setValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.servlet.jsp.tagext.Tag
getParent, setPageContext, setParent
 

Field Detail

CURRENT_ELEMENT_ID

public static final java.lang.String CURRENT_ELEMENT_ID
Name of the attribute representing stack storing ID of the current element.

See Also:
Constant Field Values

DIV_BLOCK_ELEMENT

public static final java.lang.String DIV_BLOCK_ELEMENT
DIV block element.

See Also:
Constant Field Values

SPAN_BLOCK_ELEMENT

public static final java.lang.String SPAN_BLOCK_ELEMENT
SPAN block element.

See Also:
Constant Field Values

m_strCssclass

protected java.lang.String m_strCssclass
Class for the the whole element.


m_strStyle

protected java.lang.String m_strStyle
Additional CSS style for the the whole element.


m_strType

protected java.lang.String m_strType
Type of the block element.


m_strIdSuffix

protected java.lang.String m_strIdSuffix
Suffix to append to id when generating HTML.


m_strRelatedIds

protected java.lang.String m_strRelatedIds
Flag signaling if the id of this element is related to the id of the parent element. If true then the current id is concatenated with the parent id when any code is being generated. If false then only the current id as setup for this element is being used. Null means false to speed up the code.

Constructor Detail

BlockElementTag

public BlockElementTag(java.lang.String strCssclass,
                       java.lang.String strType)
Constructor for custom tag.

Parameters:
strCssclass - - initial class of the element
strType - - type of tag - DIV or SPAN
Method Detail

doStartTag

public int doStartTag()
               throws javax.servlet.jsp.JspException

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

doEndTag

public int doEndTag()
             throws javax.servlet.jsp.JspException

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

getCssclass

public java.lang.String getCssclass()
Returns:
String - Class for the the whole element

getType

public java.lang.String getType()
Returns:
String - type of the block element

getStyle

public java.lang.String getStyle()
Returns:
String - Additional CSS style for the the whole element.

setCssclass

public void setCssclass(java.lang.String strCssclass)
Parameters:
strCssclass - - Class for the the whole element

setType

public void setType(java.lang.String strType)
Parameters:
strType - - type of the block element

setStyle

public void setStyle(java.lang.String style)
Parameters:
style - - Additional CSS style for the the whole element.

getRelatedids

public java.lang.String getRelatedids()
Returns:
String - If id of this and parent tag should be related then this attribute should say true or 1.

setRelatedids

public void setRelatedids(java.lang.String strRelatedIds)
Parameters:
strRelatedIds - - If id of this and parent tag should be related then this attribute should say true or 1.

setRelatedids

public void setRelatedids(boolean bRelatedIds)
Parameters:
bRelatedIds - - If id of this and parent tag should be related then this attribute should say true or 1.

isRelatedIdsTag

public boolean isRelatedIdsTag()
Returns:
boolean - true if the id of this and parent tag are related.

pushCurrentId

protected void pushCurrentId()
Store to the current id to be used by nested elements. This method is usually called from the doStartTag method.


popCurrentId

protected void popCurrentId()
                     throws javax.servlet.jsp.JspException
Restore to the current id to be used by nested elements. This method is usually called from the doEndTag method.

Throws:
javax.servlet.jsp.JspException - - id was stored but cannot be found anymore

getCurrentId

protected java.lang.String getCurrentId()
Restore to the current id to be used by nested elements. This method is usually called from the doEndTag method.

Returns:
String - current id pushed by parent element or empty string if none, never null

setStoredId

protected void setStoredId(boolean bIdStored)
Set up flag for stored ID

Parameters:
bIdStored - - flag signaling if id is stored or not

adjustId

protected void adjustId()
Checks if the ids of this and parent tags are related and if they are, change the id of this tag to be concatenation with the parent id. If they are not, this method will not do anything. The restoreId method will reverse this change.


restoreId

protected void restoreId()
Restore the changed (if any) made by adjustId method.



Copyright © 2003 - 2006 OpenSubsystems s.r.o.