org.apache.beehive.netui.tags.html
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, WebLogic Workshop 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 addAnchorPostRewriter(String rewriter)
          This method will add a method to be called which will handle state changes associated with an anchor post.
protected  void addAnchorRewriters()
          Add the anchor rewriter code.
protected  void addInitCode()
          This method will add the initialization code to NetUI.
 void addInitMethod(String varClass)
          This method will add a new method to the initialization code.
 void addScriptCode(String script)
          This method will add Script as top level code that runs when the page is loaded.
 void addScriptFunction(String script)
          This method will add Script as a function.
 void addTagId(String tagId, String tagName)
          Adds a tagID and tagName to the Html's getId javascript function.
protected  void defineNetUIScope(StringBuilder sb)
          This method will define the NetUI constructor.
 int doAfterBody()
          Save any body content of this tag, which will generally be the option(s) representing the values displayed to the user.
 int doEndTag()
          Write out the body content and report any errors that occured.
 int doStartTag()
           
 String getScopeId()
          return the scopeId associated with the ScriptContainer
 String getTagName()
          Returns the name of the Tag.
 boolean isInitScriptWritten()
          Returns true if the writeInitScript method has been called.
 boolean isRunAtClient()
          Return the runAtClient state of the container.
 boolean isScriptWritten()
          This method indicates that the writeScript method has been called.
protected  void localRelease()
          Release any acquired resources.
 void setRunAtClient(boolean runAtClient)
          Boolean indicating that the script container is supporting RunAtClient features.
 void setScopeId(String scopeId)
          Set the scopeId associated with the code methods
 void writeInitScript(StringBuilder sb)
          This method will output all of the Script that appears inside the tag.
 void writeScript(StringBuilder sb)
          This method will output all of the Script associated with the script reporter.
protected  String writeScriptBlock()
          This will write the script block.
 
Methods inherited from class AbstractClassicTag
addTagIdMapping, applyNamingChain, getErrorsReport, getNamingChain, getNextId, getScriptReporter, getUserLocale, hasErrors, qualifyAttribute, registerTagError, registerTagError, renderAttribute, reportAndExit, reportErrors, rewriteName, setNonEmptyValueAttribute, setRequiredValueAttribute, write
 
Methods inherited from class BodyTagSupport
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(String script)
This method will add Script as a function.

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

addScriptCode

public void addScriptCode(String script)
This method will add Script as top level code that runs when the page is loaded.

Specified by:
addScriptCode in interface IScriptReporter
Parameters:
script - the text of the script

addTagId

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

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

addInitMethod

public void addInitMethod(String varClass)
This method will add a new method to the initialization code.

Specified by:
addInitMethod in interface IScriptReporter
Parameters:
varClass - the name of the variable containing the javascript feature

addAnchorPostRewriter

public void addAnchorPostRewriter(String rewriter)
This method will add a method to be called which will handle state changes associated with an anchor post.

Specified by:
addAnchorPostRewriter in interface IScriptReporter
Parameters:
rewriter - the name of a method which will rewrite the anchor.

writeScript

public void writeScript(StringBuilder 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 StringBuffer. This value must not be null.

writeInitScript

public void writeInitScript(StringBuilder sb)
This method will output all of the Script that appears inside the tag.

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

isScriptWritten

public boolean isScriptWritten()
Description copied from interface: IScriptReporter
This method indicates that the writeScript method has been called.

Specified by:
isScriptWritten in interface IScriptReporter

isInitScriptWritten

public boolean isInitScriptWritten()
Returns true if the writeInitScript method has been called.

Specified by:
isInitScriptWritten in interface IScriptReporter
Returns:
true if the writeInitScript method has been called.

setScopeId

public void setScopeId(String scopeId)
Set the scopeId associated with the code methods


getScopeId

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


setRunAtClient

public void setRunAtClient(boolean runAtClient)
Boolean indicating that the script container is supporting RunAtClient features.

Parameters:
runAtClient - boolean flag indicating we are running at the client

isRunAtClient

public boolean isRunAtClient()
Return the runAtClient state of the container.

Specified by:
isRunAtClient in interface IScriptReporter
Returns:
boolean indicating if runAtClient features are enabled or not.

doStartTag

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

doAfterBody

public int doAfterBody()
                throws JspException
Save any body content of this tag, which will generally be the option(s) representing the values displayed to the user.

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

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

addInitCode

protected void addInitCode()
This method will add the initialization code to NetUI.


defineNetUIScope

protected void defineNetUIScope(StringBuilder sb)
This method will define the NetUI constructor. NetUI is the root level variable that acts as a container for the JavaScript infrastructure supported by NetUI.

Parameters:
sb - A StringBuffer to write the new script block into

addAnchorRewriters

protected void addAnchorRewriters()
Add the anchor rewriter code. Rewriter code is only on when runAtClient is set on the script container.


writeScriptBlock

protected String writeScriptBlock()
This will write the script block.

Returns:
String

localRelease

protected void localRelease()
Release any acquired resources.

Overrides:
localRelease in class AbstractClassicTag