org.apache.beehive.netui.tags.javascript
Class ScriptContainer

Object
  extended by TagSupport
      extended by BodyTagSupport
          extended by AbstractClassicTag
              extended by ScriptContainer
All Implemented Interfaces:
Serializable, BodyTag, IterationTag, JspTag, Tag, INetuiTag, IScriptReporter
Direct Known Subclasses:
Html

public class ScriptContainer
extends AbstractClassicTag
implements IScriptReporter

Acts as a container that will bundle up JavaScript created by other NetUI tags, and output it within a single <script> tag. This is especially needed for Portal web applications, because they often cannot rely on having <html> ... </html> tags to provide a default container. In a portlet, some JSP pages might be included into other JSP pages. Having redundant <html> ... </html> tags in the rendered portlet JSP can result in display problems for some browsers. However, omitting the <html> tag (and the container it provides) can result in cluttered code, especially where Javascript appears in the file. To solve this issue, Beehive provides the <netui:scriptContainer> tag.

See Also:
Serialized Form
Example
The <netui:scriptContainer> ... </netui:scriptContainer tag set simply encloses other NetUI tags that you want to belong to that script container. The first <netui:scriptContainer> tag should appear after the JSP's <body> tag. The closing </netui:scriptContainer> tag should appear before the JSP's </body> tag.

Field Summary
 
Fields inherited from class AbstractClassicTag
DefaultNamingChain, EMPTY_STRING, NETUI_UNIQUE_CNT
 
Fields inherited from class BodyTagSupport
bodyContent
 
Fields inherited from class TagSupport
id, pageContext
 
Fields inherited from interface BodyTag
EVAL_BODY_BUFFERED, EVAL_BODY_TAG
 
Fields inherited from interface IterationTag
EVAL_BODY_AGAIN
 
Fields inherited from interface Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
 
Constructor Summary
ScriptContainer()
           
 
Method Summary
 void addLegacyTagIdMappings(String tagId, String tagName)
          Adds a tagID and tagName to the Html's getId javascript function.
 void addScriptFunction(ScriptPlacement placement, String script)
          This method will add Script as a function.
 void addTagIdMappings(String tagId, String realId, String realName)
          This will add the mapping between the tagId and the real name to the NameMap hashmap.
 int doEndTag()
          Write out the body content and report any errors that occured.
 int doStartTag()
           
 String getIdScope()
          return the scopeId associated with the ScriptContainer
protected  String getRealIdScope()
          This method will return the real scope id for the script container.
 String getTagName()
          Returns the name of the Tag.
protected  void localRelease()
          Release any acquired resources.
 void setGenerateIdScope(boolean genScopeValue)
          If true generate a scope id for this script container.
 void setIdScope(String idScope)
          Set the idScope associated with the code methods
protected  void writeAfterBlocks(AbstractRenderAppender sb)
           
protected  void writeBeforeBlocks(AbstractRenderAppender sb)
           
protected  void writeFrameworkScript(AbstractRenderAppender sb)
          This will write the script block.
 void writeScript(AbstractRenderAppender sb)
          This method will output all of the Script associated with the script reporter.
 
Methods inherited from class AbstractClassicTag
applyNamingChain, getErrorsReport, getIdForTagId, getNamingChain, getNextId, getScriptReporter, getUserLocale, hasErrors, qualifyAttribute, registerTagError, registerTagError, reportAndExit, reportErrors, rewriteName, setNonEmptyValueAttribute, setRequiredValueAttribute, write
 
Methods inherited from class BodyTagSupport
doAfterBody, doInitBody, getBodyContent, getPreviousOut, release, setBodyContent
 
Methods inherited from class TagSupport
findAncestorWithClass, getId, getParent, getValue, getValues, removeValue, setId, setPageContext, setParent, setValue
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface Tag
getParent, setPageContext, setParent
 

Constructor Detail

ScriptContainer

public ScriptContainer()
Method Detail

getTagName

public String getTagName()
Returns the name of the Tag.

Specified by:
getTagName in interface INetuiTag
Specified by:
getTagName in class AbstractClassicTag
Returns:
the name of the tag.

addScriptFunction

public void addScriptFunction(ScriptPlacement placement,
                              String script)
This method will add Script as a function.

Specified by:
addScriptFunction in interface IScriptReporter
Parameters:
placement -
script - the text of the function. This value must not be null.

addLegacyTagIdMappings

public void addLegacyTagIdMappings(String tagId,
                                   String tagName)
Adds a tagID and tagName to the Html's getId javascript function.

Specified by:
addLegacyTagIdMappings in interface IScriptReporter
Parameters:
tagId - - the id of a child tag.
tagName - - the name of a child tag.

addTagIdMappings

public void addTagIdMappings(String tagId,
                             String realId,
                             String realName)
This will add the mapping between the tagId and the real name to the NameMap hashmap.

Specified by:
addTagIdMappings in interface IScriptReporter
Parameters:
tagId -
realId -
realName -

writeScript

public void writeScript(AbstractRenderAppender sb)
This method will output all of the Script associated with the script reporter.

Specified by:
writeScript in interface IScriptReporter
Parameters:
sb - The script is written into the provided StringBuilder. This value must not be null.

setIdScope

public void setIdScope(String idScope)
Set the idScope associated with the code methods


getIdScope

public String getIdScope()
return the scopeId associated with the ScriptContainer


setGenerateIdScope

public void setGenerateIdScope(boolean genScopeValue)
If true generate a scope id for this script container. If this is set to true and a scopeId is also set, the scopeId set will be written.


doStartTag

public int doStartTag()
               throws JspException
Specified by:
doStartTag in interface Tag
Overrides:
doStartTag in class BodyTagSupport
Throws:
JspException

doEndTag

public int doEndTag()
             throws JspException
Write out the body content and report any errors that occured.

Specified by:
doEndTag in interface Tag
Overrides:
doEndTag in class BodyTagSupport
Throws:
JspException - if a JSP exception has occurred

getRealIdScope

protected String getRealIdScope()
This method will return the real scope id for the script container. It

Returns:

writeBeforeBlocks

protected void writeBeforeBlocks(AbstractRenderAppender sb)

writeAfterBlocks

protected void writeAfterBlocks(AbstractRenderAppender sb)

writeFrameworkScript

protected void writeFrameworkScript(AbstractRenderAppender sb)
This will write the script block.


localRelease

protected void localRelease()
Release any acquired resources.

Overrides:
localRelease in class AbstractClassicTag