wt.clients.util
Class WTJSObject

java.lang.Object
  extended bywt.clients.util.WTJSObject

public class WTJSObject
extends Object

A wrapper class for netscape.javascript.JSObject. This class can be used by Windchill client applications as a proxy for the netscape.javascript.JSObject. Using this class avoids needing the netscape.javascript.* classes in the Windchill codebase. The classes are supplied by the browsers at runtime.

Supported API: true

Extendable: false


Field Summary
private  Applet applet
           
private  Object jsObject
           
private static Method jsoCallMethod
           
private static Method jsoGetWindowMethod
           
private  boolean runningInMSIE
           
 
Constructor Summary
protected WTJSObject(Applet applet, Object object)
          Protected constructor.
 
Method Summary
 Object call(String methodName, Object[] args)
          Invoke the named method with the specified arguments.
protected static void callJavaScriptFunctionViaShowDoc(Applet applet, String methodName, Object[] args)
          Call JavaScript function in the current page via AppletContext.showDocument().
protected  void callJavaScriptFunctionViaShowDoc(String methodName, Object[] args)
          Call JavaScript function in the current page via AppletContext.showDocument().
static void callWithoutReturnValue(Applet applet, String methodName, Object[] args)
          Same as instance method of the same name except that this variation avoids creating a WTJSObject (and thus calling JSObject.getWindows(applet)) where this is unnecessary.
 void callWithoutReturnValue(String methodName, Object[] args)
          This method can be used whenever the return value of the given function call is not of interest.
protected static String escapeJavaScriptStringArgForJSUrlCall(String str)
          Escape the incoming string for use as an argument to a JavaScript function call via a 'javascript:funcName(...)' URL.
protected  Applet getApplet()
          Get the contained applet.
protected  Object getJSObject()
          Get the contained JSObject.
static WTJSObject getWindow(Applet applet)
          Static method to obtain initial WTJSObject for applet's browser window.
 boolean isRunningInMSIE()
           
static boolean isRunningInMSIE(Applet applet)
          Determine whether the given applet is running within MSIE.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

applet

private Applet applet

jsObject

private Object jsObject

runningInMSIE

private boolean runningInMSIE

jsoGetWindowMethod

private static Method jsoGetWindowMethod

jsoCallMethod

private static Method jsoCallMethod
Constructor Detail

WTJSObject

protected WTJSObject(Applet applet,
                     Object object)
Protected constructor. The calling program obtains an instance of the class through the getWindow() method.

Method Detail

getWindow

public static WTJSObject getWindow(Applet applet)
                            throws WTException
Static method to obtain initial WTJSObject for applet's browser window.

Throws:
WTException

call

public Object call(String methodName,
                   Object[] args)
            throws WTException
Invoke the named method with the specified arguments.

Throws:
WTException

callWithoutReturnValue

public void callWithoutReturnValue(String methodName,
                                   Object[] args)
                            throws WTException
This method can be used whenever the return value of the given function call is not of interest. In this case when it is safer to do so we use showDocument() of a JavaScript URL to invoke the JavaScript function instead of JSObject.

Throws:
WTException

callWithoutReturnValue

public static void callWithoutReturnValue(Applet applet,
                                          String methodName,
                                          Object[] args)
                                   throws WTException
Same as instance method of the same name except that this variation avoids creating a WTJSObject (and thus calling JSObject.getWindows(applet)) where this is unnecessary. This method should thus both have better performance and be more convenient for a single JavaScript call from a given applet instance. The instance method, on the other hand, does all setup work once and thus is better for repeated calls from a given applet instance. Currently this method uses JSObject if the browser is MSIE, and showDocument() if the browser is Mozilla/Netscape, because of a known JSObject issue with certain Mozilla/Netscape versions that return Javascript strings as some other sort of Javascript object, which causes problems with certain Javascript calls. If a particular applet prefers to always use JSObject and never use showDocument() regardless of browser/version, such as to support the passing of strings with multibyte characters from applet to page, then an applet parameter called "forceJSObject" should be set to "true". (SPR 1093978)

Throws:
WTException

callJavaScriptFunctionViaShowDoc

protected static void callJavaScriptFunctionViaShowDoc(Applet applet,
                                                       String methodName,
                                                       Object[] args)
                                                throws WTException
Call JavaScript function in the current page via AppletContext.showDocument(). Note this does not allow us to obtain the return value.

Throws:
WTException

callJavaScriptFunctionViaShowDoc

protected void callJavaScriptFunctionViaShowDoc(String methodName,
                                                Object[] args)
                                         throws WTException
Call JavaScript function in the current page via AppletContext.showDocument(). Note this does not allow us to obtain the return value.

Throws:
WTException

escapeJavaScriptStringArgForJSUrlCall

protected static String escapeJavaScriptStringArgForJSUrlCall(String str)
Escape the incoming string for use as an argument to a JavaScript function call via a 'javascript:funcName(...)' URL. Note that surrounding quoting is included in this (i.e. the caller should not quote the result).


isRunningInMSIE

public static boolean isRunningInMSIE(Applet applet)
Determine whether the given applet is running within MSIE. Note that the AppletContext must be set by this point for this to work.


isRunningInMSIE

public boolean isRunningInMSIE()

getJSObject

protected Object getJSObject()
Get the contained JSObject.


getApplet

protected Applet getApplet()
Get the contained applet.