SilverStream
Application Server 3.5

com.sssw.shr.page
Interface AgiJavaScriptEnhanced

All Known Implementing Classes:
AgpTag, AgpText

public interface AgiJavaScriptEnhanced

Optional page control interface for controls that take advantage of JavaScript.


Method Summary
 void generateFunction(String func, Writer writer)
          Invoked for every function or method name returned by getFunctionNames() and getMethodNames().
 void generateRepaintScript(String namespace, Writer writer, String objectref)
          Generates the script for updating the value of the control.
 void generateScriptInitializers(String namesapce, Writer writer)
          Generates the script to be inserted into the page loaded event handler.
 boolean getEnableHTMLGeneration()
          Returns whether this control will generate HTML.
 String getFunctionNameForMethod(String methodname)
          Returns the function name of the specified methods.
 String[] getFunctionNames()
          Returns the names of the JavaScript methods used by this control.
 String[] getMethodNames()
          Returns the names of the JavaScript methods used by this control.
 String getScriptObjectName(String namespace)
          Returns a string that gives the scriptable element reference.
 boolean isHTMLRepaintPending()
          Returns whether the state of this control needs a complete HTML generation to refresh.
 boolean isJavaScriptRepaintPending()
          Returns whether the state of this control needs to be updated to the browser.
 

Method Detail

getFunctionNames

public String[] getFunctionNames()
Returns the names of the JavaScript methods used by this control.
Usage:

The difference between functions and methods is that methods are part of the JavaScript object representing this control. Therefore, methods are invoked differently.

For example, if this object is called "Button1" on the page, then a method such as "flash" is invoked by "this.Button1.flash()" in a page method.

Example:
getFunctionNameForMethod(String methodname)
See Also:
AgiJavaScriptEnhanced.getFunctionNameForMethod(String methodname), AgiJavaScriptEnhanced.getFunctionNames()

generateFunction

public void generateFunction(String func,
                             Writer writer)
                      throws IOException
Invoked for every function or method name returned by getFunctionNames() and getMethodNames(). Implementation of this method should generate the script for the specified JavaScript function.
Parameters:
func - A string naming the function.
writer - A character output stream.
Usage:

Refer to getFunctionNames() for convention of naming functions.

Example:

The following Java code generates a Javascript function named "com_sssw_ShowHelloWorld" which brings up an alert dialog.

 	writer.write("\nfunction com_sssw_ShowHelloWorld()
 		{alert('Hello World');}");
 

getMethodNames

public String[] getMethodNames()
Returns the names of the JavaScript methods used by this control.
Usage:

The difference between functions and methods is that methods are part of the JavaScript object representing this control. Therefore, methods are invoked differently.

For example, if this object is called "Button1" on the page, then a method such as "flash" is invoked by "this.Button1.flash()" in a page method.

Example:
 
See Also:
AgiJavaScriptEnhanced.getFunctionNameForMethod(String methodname), AgiJavaScriptEnhanced.getFunctionNames()

getFunctionNameForMethod

public String getFunctionNameForMethod(String methodname)
Returns the function name of the specified methods.
Parameters:
methodname - a string representing the method name.
Returns:
the function name of the specified methods
Example:
 
See Also:
AgiJavaScriptEnhanced.getFunctionNames(), AgiJavaScriptEnhanced.getMethodNames()

getScriptObjectName

public String getScriptObjectName(String namespace)
Returns a string that gives the scriptable element reference.
Parameters:
namespace - a string representing the namespace.
Returns:
the scriptable element name.
Usage:

It should be a document-relative reference. For example, if the JavaScript object of this control can be referenced by document.forms[0].elements["S5_"], then forms[0].elements["S5_"] should be returned.

Note that in some situations, the control may not be in the first form in a page, controls should generally ask the page for the form reference.

Example:
 

isHTMLRepaintPending

public boolean isHTMLRepaintPending()
Returns whether the state of this control needs a complete HTML generation to refresh.
Returns:
true if the state of this control needs a complete HTML generation to refresh.
Usage:

This method is used only with the script-based repaint mode, not currently implemented in SilverStream 2.0. This method name is reserved for future release. Custom page controls designed for SilverStream 2.0 should always return true.

Example:
 
See Also:
AgiJavaScriptEnhanced.generateRepaintScript(String namespace, Writer writer, String objectref), AgiJavaScriptEnhanced.isJavaScriptRepaintPending()

isJavaScriptRepaintPending

public boolean isJavaScriptRepaintPending()
Returns whether the state of this control needs to be updated to the browser.
Returns:
true if the state of this control needs to be updated to the browser. But it can be achieved by only using javascript
Usage:

This method is used only with the script-based repaint mode, not currently implemented in SilverStream 2.0. This method name is reserved for future release. Custom page controls designed for SilverStream 2.0 should always return true.

Example:
 
See Also:
AgiJavaScriptEnhanced.isHTMLRepaintPending()

generateRepaintScript

public void generateRepaintScript(String namespace,
                                  Writer writer,
                                  String objectref)
                           throws IOException
Generates the script for updating the value of the control.
Parameters:
namespace - a string containing the namespace.
writer - a character output stream.
objectref - a string referencing the object.
Usage:

This method is used only with the script-based repaint mode, not currently implemented in SilverStream 2.0. This method name is reserved for future release. Custom page controls designed for SilverStream 2.0 should simply do nothing and return.

This method will get called only if every control on the page reports false to isHTMLRepaintPending and, this control indicates that JavaScriptRepaint is pending. You can use the objectref to refer to this object.

Example:
 
See Also:
AgiJavaScriptEnhanced.isHTMLRepaintPending()

getEnableHTMLGeneration

public boolean getEnableHTMLGeneration()
Returns whether this control will generate HTML.
Returns:
true if this control will generate HTML
Example:
 

generateScriptInitializers

public void generateScriptInitializers(String namesapce,
                                       Writer writer)
                                throws IOException
Generates the script to be inserted into the page loaded event handler.
Parameters:
namesapce - a string containing the namespace.
writer - a character output stream.
Usage:

Use this method to generate any scripts that need to go into the page loaded event. For example, controls can generate scripts to preload the images needed in the actual HTML.

Example:

The following Java code generates JavaScript that preloads an image.

 	writer.write(" (new Image()).src = \"someimage.gif\";");
 

SilverStream
Application Server 3.5