wt.templateutil.components
Class HTMLJavaScriptComponent

java.lang.Object
  extended bywt.templateutil.components.HTMLComponent
      extended bywt.templateutil.components.DefaultHTMLComponent
          extended bywt.templateutil.components.HTMLJavaScriptComponent
Direct Known Subclasses:
HTMLUrlAwareTextFieldComponent

public abstract class HTMLJavaScriptComponent
extends DefaultHTMLComponent

A DefaultHTMLComponent that ensures that JavaScript scripts associated with multiple elements on a page are only printed once. Subclasses must only implement the setIncludedScripts() method, which gets passed a String[] that indicates which scripts to include with the component. The Strings in the String[] must be key values in a resourceBundle that can be passed as a parameter to the constructor, but defaults to an instance of wt.htmlutil.htmlutilResource.


Field Summary
private  String[] includedScripts
           
private  JavaScriptManager javaScriptManager
           
protected static String ONCLICK
           
protected static String ONKEYPRESS
           
protected static String ONLOAD
           
protected static String ONMOUSEDOWN
           
protected static String ONMOUSEOVER
           
protected static String ONMOUSEUP
           
protected static String ONRESET
           
protected static String ONRESIZE
           
protected static String ONSUBMIT
           
private  ResourceBundle resourceBundle
           
 
Fields inherited from class wt.templateutil.components.DefaultHTMLComponent
defaultComponent
 
Fields inherited from class wt.templateutil.components.HTMLComponent
CLASS, COMPONENT_ID, COMPONENT_ID_SEPARATOR, CREATE, DEFAULT_SERVICE_NAME, DEFAULTS_ONLY, EMPTY_STRING, ID, ID_US_ENGLISH_LOCALE, NAME, NULLVALUE, PRINT_TAG_ATTR, SERVICENAME, TAG, UPDATE, VIEW
 
Constructor Summary
HTMLJavaScriptComponent()
           
HTMLJavaScriptComponent(String resourceBundleName)
           
 
Method Summary
protected  String constructEvent(String event, String handler)
          The constructEvent methods provide a clean way to name JavaScript variables, simply using the key values from resourceBundle.
protected  String constructEvent(String event, String handler, String param)
           
protected  String constructEvent(String event, String handler, String[] params)
           
protected  String[] getIncludedScripts()
           
 void init(String selector, Object value, HTMLComponentFactory componentFactory, String mode, Properties props)
          The javaScriptManager is grabbed from props.
protected  void setIncludedScripts(String[] in)
           
 String show(Object value, Properties formData, OutputStream os, Locale locale)
          This method is the main control for the Display of all HTMLComponent subclasses.
 
Methods inherited from class wt.templateutil.components.DefaultHTMLComponent
endComponent, setTagListArray, startComponent
 
Methods inherited from class wt.templateutil.components.HTMLComponent
appendID, appendID, appendToID, appendToID, createIDForComponent, getHtmlComponents, getID, getIdProp, getName, getOID, getPrintWriter, getRealValue, getServiceName, getState, getTag, getTagID, getTagIDKey, getTagList, getTagSettings, getURLFactory, insertID, insertID, isInheritStyle, isPrintTagAttributes, isUseDefaultsOnly, main, putTagID, putTagID, removeID, removeTagID, setHtmlComponents, setID, setInheritStyle, setName, setPrintTagAttributes, setServiceName, setState, setTag, setTagList, setTagListDefaults, setTagSettings, setTagValue, setUseDefaultsOnly, showSubComponents
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ONCLICK

protected static final String ONCLICK
See Also:
Constant Field Values

ONKEYPRESS

protected static final String ONKEYPRESS
See Also:
Constant Field Values

ONMOUSEOVER

protected static final String ONMOUSEOVER
See Also:
Constant Field Values

ONMOUSEDOWN

protected static final String ONMOUSEDOWN
See Also:
Constant Field Values

ONMOUSEUP

protected static final String ONMOUSEUP
See Also:
Constant Field Values

ONRESIZE

protected static final String ONRESIZE
See Also:
Constant Field Values

ONLOAD

protected static final String ONLOAD
See Also:
Constant Field Values

ONSUBMIT

protected static final String ONSUBMIT
See Also:
Constant Field Values

ONRESET

protected static final String ONRESET
See Also:
Constant Field Values

includedScripts

private String[] includedScripts

javaScriptManager

private JavaScriptManager javaScriptManager

resourceBundle

private ResourceBundle resourceBundle
Constructor Detail

HTMLJavaScriptComponent

public HTMLJavaScriptComponent(String resourceBundleName)

HTMLJavaScriptComponent

public HTMLJavaScriptComponent()
Method Detail

init

public void init(String selector,
                 Object value,
                 HTMLComponentFactory componentFactory,
                 String mode,
                 Properties props)
The javaScriptManager is grabbed from props.

Overrides:
init in class DefaultHTMLComponent
Parameters:
selector -
value -
componentFactory -
mode -
props -

show

public String show(Object value,
                   Properties formData,
                   OutputStream os,
                   Locale locale)
Description copied from class: HTMLComponent
This method is the main control for the Display of all HTMLComponent subclasses. It first calls startComponent, then showSubComponents, and then endComponent. It returns a string that is the concatenation of the results of these three methods. A call to show() should be all that is needed to display any subclass component.

Supported API: true

Overrides:
show in class HTMLComponent
Parameters:
value -
formData -
os -
locale -
Returns:
String

setIncludedScripts

protected void setIncludedScripts(String[] in)

getIncludedScripts

protected String[] getIncludedScripts()

constructEvent

protected String constructEvent(String event,
                                String handler)
The constructEvent methods provide a clean way to name JavaScript variables, simply using the key values from resourceBundle.

Parameters:
event - The event to be constructed.
handler - The key from resourceBundle.

constructEvent

protected String constructEvent(String event,
                                String handler,
                                String param)
Parameters:
param - An extra argument to the event handler.

constructEvent

protected String constructEvent(String event,
                                String handler,
                                String[] params)
Parameters:
params - An arbitrary number of arguments to the event handler.