com.sibvisions.rad.ui.swing.impl
Class JSBridge

java.lang.Object
  extended by com.sibvisions.rad.ui.swing.impl.JSBridge

public class JSBridge
extends Object

The JSBridge encapsulates the access to javascript functions. It's only possible to access javascript in a web browser. The constructor will throw an exception if it's not possible to access the javascript engine.


Constructor Summary
JSBridge(Applet pApplet)
          Creates a new instance of JSBridge for an applet.
 
Method Summary
 Object call(String pMethod, Object... pParams)
          Calls a javascript method.
 void close()
          Closes the window.
 Object get(String pMember)
          Retrieves a named member of a JavaScript object.
 String getCookie(String pName)
          Gets the value of a cookie.
 Object getIntern(Object pObject, String pMember)
          Retrieves a named member of a JavaScript object.
 String getLocation()
          Gets the current location.
 String getTitle()
          Gets the current window title.
 void openWindow(String pURL, String pTarget, int iX, int iY, int iWidth, int iHeight, boolean pCenter)
          Opens a new browser window.
 void requestFocus()
          Requests the focus.
 void set(String pMember, Object pValue)
          Sets a named member of a JavaScript object.
 void setCookie(String pName, String pValue, long pSecondsValid)
          Sets the value for a cookie.
 void setLocation(String pLocation)
          Sets the location.
 void setTitle(String pTitle)
          Sets the window title.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JSBridge

public JSBridge(Applet pApplet)
         throws Throwable
Creates a new instance of JSBridge for an applet.

Parameters:
pApplet - the applet
Throws:
Throwable - if it's not possible to detect the window object of the applet
Method Detail

setTitle

public void setTitle(String pTitle)
              throws Throwable
Sets the window title.

Parameters:
pTitle - the title
Throws:
Throwable - if the access to the document object fails

getTitle

public String getTitle()
                throws Throwable
Gets the current window title.

Returns:
the title
Throws:
Throwable - if the access to the document object fails

setLocation

public void setLocation(String pLocation)
                 throws Throwable
Sets the location.

Parameters:
pLocation - the location
Throws:
Throwable - if the access to the location object fails

getLocation

public String getLocation()
                   throws Throwable
Gets the current location.

Returns:
the location
Throws:
Throwable - if the access to the location object fails

close

public void close()
           throws Throwable
Closes the window. This operation doesn't work with firefox if the window was not opened through a script.

Throws:
Throwable - if the close operation fails

requestFocus

public void requestFocus()
                  throws Throwable
Requests the focus.

Throws:
Throwable - if the focus can't be set

openWindow

public void openWindow(String pURL,
                       String pTarget,
                       int iX,
                       int iY,
                       int iWidth,
                       int iHeight,
                       boolean pCenter)
                throws Throwable
Opens a new browser window.

Parameters:
pURL - the url for the window
pTarget - the target name
iX - the x location on screen
iY - the y location on screen
iWidth - the window width
iHeight - the window height
pCenter - true to center the window (only used if height or width are defined)
Throws:
Throwable - if it's not possible to open the window

call

public Object call(String pMethod,
                   Object... pParams)
            throws Throwable
Calls a javascript method.

Parameters:
pMethod - the method name
pParams - the parameters
Returns:
the result of the method call or null if the method doesn't return a value
Throws:
Throwable - if the method is not available or the call failed

set

public void set(String pMember,
                Object pValue)
         throws Throwable
Sets a named member of a JavaScript object. Equivalent to "this.name = value" in JavaScript.

Parameters:
pMember - the member name
pValue - the value for the member
Throws:
Throwable - if the member or the parent object is not available

get

public Object get(String pMember)
           throws Throwable
Retrieves a named member of a JavaScript object. Equivalent to "this.name" in JavaScript.

Parameters:
pMember - the member name
Returns:
the value
Throws:
Throwable - if the member is or the parent object is not available

getIntern

public Object getIntern(Object pObject,
                        String pMember)
                 throws Throwable
Retrieves a named member of a JavaScript object. Equivalent to "this.name" in JavaScript.

Parameters:
pObject - the object from which the method should be called
pMember - the member name
Returns:
the value
Throws:
Throwable - if the member is or the parent object is not available

setCookie

public void setCookie(String pName,
                      String pValue,
                      long pSecondsValid)
               throws Throwable
Sets the value for a cookie.

Parameters:
pName - the cookie name
pValue - the value to set
pSecondsValid - sets the maximum age of the cookie in seconds
Throws:
Throwable - if the cookie can not be set

getCookie

public String getCookie(String pName)
                 throws Throwable
Gets the value of a cookie.

Parameters:
pName - the cookie name
Returns:
the value or null if the cookie is not available
Throws:
Throwable - if it's not possible to access the cookie list


Copyright © 2009 SIB Visions GmbH. All Rights Reserved.