org.jclientpages.page
Class AbstractClientPage

java.lang.Object
  extended by org.jclientpages.page.AbstractClientPage
All Implemented Interfaces:
ClientPage
Direct Known Subclasses:
BshClientPage

public abstract class AbstractClientPage
extends java.lang.Object
implements ClientPage

This is the abstract class that implements Applet based JCP.
It is responsible of creating the JavaScript-Java bridge and implements all the facility methods declared in the ClientPage interface

Author:
Luigi Dell'Aquila (luigi.dellaquila--at--gmail.com)

Constructor Summary
AbstractClientPage()
           
 
Method Summary
 void alert(java.lang.Object alertObject)
           
 void alert(java.lang.String alertString)
          displays an alert with the given string in the current window (blocking)
 java.lang.Object call(java.lang.String methodName, java.lang.Object[] args)
          invokes a JavaScript function in the current window
 java.lang.Boolean confirm(java.lang.String confirmString)
          displays a confirm dialog box (blocking)
 ClientPageNode createElement(java.lang.String tagName)
          creates a new DOM element
 ClientPageNode createTextNode(java.lang.String text)
          creates a new DOM text element
 java.lang.Object eval(java.lang.String iString)
          evaluates a JavaScript expression in the current window
 ClientPageNode getElementById(java.lang.String id)
          searches for a node given its HTML id
 ClientPageNode[] getElementsByExpression(java.lang.String exp)
          searches for nodes evaluating a JavaScript expression (that returns an array of nodes).
 ClientPageNode[] getElementsByName(java.lang.String name)
          searches for nodes given an HTML name
IMPORTANT - due to a IE7 bug (and our workaround...) in some cases this method is a bit slow...
 ClientPageNode[] getElementsByTagName(java.lang.String name)
          searches for nodes given an HTML tag name
 netscape.javascript.JSObject getWindow()
          returns the JSObject representing the current window
 void init()
          is invoked by the JCP engine when the page is compiled and instantiated
 void onLoad()
          is invoked by the JCP engine when the page is loaded, immediately after the init() method.
 void setWindow(netscape.javascript.JSObject window)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jclientpages.page.ClientPage
executeInternal, getMethods
 

Constructor Detail

AbstractClientPage

public AbstractClientPage()
Method Detail

getWindow

public netscape.javascript.JSObject getWindow()
Description copied from interface: ClientPage
returns the JSObject representing the current window

Specified by:
getWindow in interface ClientPage
Returns:
the JSObject representing the current window

setWindow

public void setWindow(netscape.javascript.JSObject window)
Specified by:
setWindow in interface ClientPage

onLoad

public void onLoad()
Description copied from interface: ClientPage
is invoked by the JCP engine when the page is loaded, immediately after the init() method.
A JClientPage can override this method in order to execute custom code after page load

Specified by:
onLoad in interface ClientPage

init

public final void init()
Description copied from interface: ClientPage
is invoked by the JCP engine when the page is compiled and instantiated

Specified by:
init in interface ClientPage

getElementById

public ClientPageNode getElementById(java.lang.String id)
Description copied from interface: ClientPage
searches for a node given its HTML id

Specified by:
getElementById in interface ClientPage
Parameters:
id - the HTML id of the node
Returns:
the node, null if no element with the given id exists in the page

getElementsByTagName

public ClientPageNode[] getElementsByTagName(java.lang.String name)
Description copied from interface: ClientPage
searches for nodes given an HTML tag name

Specified by:
getElementsByTagName in interface ClientPage
Parameters:
name - the tag name of the nodes
Returns:
an array of nodes having the given tag name, a zero elements array if no node exists with the given tag name or given tag name is null

getElementsByName

public ClientPageNode[] getElementsByName(java.lang.String name)
Description copied from interface: ClientPage
searches for nodes given an HTML name
IMPORTANT - due to a IE7 bug (and our workaround...) in some cases this method is a bit slow...

Specified by:
getElementsByName in interface ClientPage
Parameters:
name - the name of the nodes
Returns:
an array of nodes having the given name, a zero elements array if no node exists with the given name or given name is null

getElementsByExpression

public ClientPageNode[] getElementsByExpression(java.lang.String exp)
Description copied from interface: ClientPage
searches for nodes evaluating a JavaScript expression (that returns an array of nodes). This method can be useful to integrate JClientPages with other JavaScript frameworks (such as JQuery...)

Specified by:
getElementsByExpression in interface ClientPage
Parameters:
exp - the expression to be evaluated
Returns:
an array of resulting nodes

createElement

public ClientPageNode createElement(java.lang.String tagName)
Description copied from interface: ClientPage
creates a new DOM element

Specified by:
createElement in interface ClientPage
Parameters:
tagName - the tag name
Returns:
the new element

createTextNode

public ClientPageNode createTextNode(java.lang.String text)
Description copied from interface: ClientPage
creates a new DOM text element

Specified by:
createTextNode in interface ClientPage
Parameters:
text - the content of the text element
Returns:
the new element

call

public java.lang.Object call(java.lang.String methodName,
                             java.lang.Object[] args)
Description copied from interface: ClientPage
invokes a JavaScript function in the current window

Specified by:
call in interface ClientPage
Parameters:
methodName - the function name
args - the function arguments
Returns:
the value returned by the function call

eval

public java.lang.Object eval(java.lang.String iString)
Description copied from interface: ClientPage
evaluates a JavaScript expression in the current window

Specified by:
eval in interface ClientPage
Parameters:
iString - the expression to be evaluated
Returns:
the result of the expression evaluation

alert

public void alert(java.lang.String alertString)
Description copied from interface: ClientPage
displays an alert with the given string in the current window (blocking)

Specified by:
alert in interface ClientPage

alert

public void alert(java.lang.Object alertObject)

confirm

public java.lang.Boolean confirm(java.lang.String confirmString)
Description copied from interface: ClientPage
displays a confirm dialog box (blocking)

Specified by:
confirm in interface ClientPage
Parameters:
confirmString - the text displayed in the dialog
Returns:
true if the user clicked on OK button, false otherwise