Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 


Eclipse Platform
Release 3.5

org.eclipse.swt.browser
Class BrowserFunction


java.lang.Object
  extended by 
org.eclipse.swt.browser.BrowserFunction

public class BrowserFunction
extends Object

Instances of this class represent java-side "functions" that are invokable from javascript. Browser clients define these functions by subclassing BrowserFunction and overriding its function(Object[]) method. This method will be invoked whenever javascript running in the Browser makes a call with the function's name.

Application code must explicitly invoke the BrowserFunction.dispose() method to release the resources managed by each instance when those instances are no longer required. Since there is usually a correlation between the registering of BrowserFunction(s) in a Browser and the loading of a page in the Browser that is aware of these functions, the LocationListener.changed() listener is often a good place to do this.

Note that disposing a Browser automatically disposes all BrowserFunctions associated with it.

Since:
3.5
See Also:
dispose(), function(Object[]), LocationListener.changed(LocationEvent)

Constructor Summary
BrowserFunction ( Browser browser, String name)
          Constructs a new instance of this class, which will be invokable by javascript running in the specified Browser.
 
Method Summary
 void dispose ()
          Disposes of the resources associated with this BrowserFunction.
  Object function ( Object[] arguments)
          Subclasses should override this method.
  Browser getBrowser ()
          Returns the Browser whose pages can invoke this BrowserFunction.
  String getName ()
          Returns the name that javascript can use to invoke this BrowserFunction.
 boolean isDisposed ()
          Returns true if this BrowserFunction has been disposed and false otherwise.
 
Methods inherited from class java.lang. Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BrowserFunction

public BrowserFunction(
Browser browser,
                       
String name)
Constructs a new instance of this class, which will be invokable by javascript running in the specified Browser.

You must dispose the BrowserFunction when it is no longer required. A common place to do this is in a LocationListener.changed() listener.

Parameters:
browser - the browser whose javascript can invoke this function
name - the name that javascript will use to invoke this function
Throws:
IllegalArgumentException -
  • ERROR_NULL_ARGUMENT - if the browser is null
  • ERROR_NULL_ARGUMENT - if the name is null
SWTException -
  • ERROR_WIDGET_DISPOSED - if the browser has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
See Also:
dispose(), LocationListener.changed(LocationEvent)
Method Detail

dispose

public void dispose()
Disposes of the resources associated with this BrowserFunction. Applications must dispose of all BrowserFunctions that they create.

Note that disposing a Browser automatically disposes all BrowserFunctions associated with it.


function

public 
Object function(
Object[] arguments)
Subclasses should override this method. This method is invoked when the receiver's function is called from javascript. If all of the arguments that are passed to the javascript function call are of supported types then this method is invoked with the argument values converted as follows: javascript null or undefined -> null javascript number -> java.lang.Double javascript string -> java.lang.String javascript boolean -> java.lang.Boolean javascript array whose elements are all of supported types -> java.lang.Object[] If any of the Javascript arguments are of unsupported types then the function invocation will fail and this method will not be called. This method must return a value with one of these supported types to the javascript caller (note that any subclass of java.lang.Number will be successfully converted to a javascript number).

Parameters:
arguments - the javascript arguments converted to java equivalents
Returns:
the value to return to the javascript caller
Throws:
SWTException -
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
  • ERROR_FUNCTION_DISPOSED when the BrowserFunction has been disposed

getBrowser

public 
Browser getBrowser()
Returns the Browser whose pages can invoke this BrowserFunction.

Returns:
the Browser associated with this BrowserFunction
Throws:
SWTException -
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
  • ERROR_FUNCTION_DISPOSED when the BrowserFunction has been disposed

getName

public 
String getName()
Returns the name that javascript can use to invoke this BrowserFunction.

Returns:
the BrowserFunction's name
Throws:
SWTException -
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
  • ERROR_FUNCTION_DISPOSED when the BrowserFunction has been disposed

isDisposed

public boolean isDisposed()
Returns true if this BrowserFunction has been disposed and false otherwise.

This method gets the dispose state for the BrowserFunction. When a BrowserFunction has been disposed it is an error to invoke any of its methods.

Note that disposing a Browser automatically disposes all BrowserFunctions associated with it.

Returns:
true if this BrowserFunction has been disposed and false otherwise

Eclipse Platform
Release 3.5

Guidelines for using Eclipse APIs.

Copyright (c) Eclipse contributors and others 2000, 2008. All rights reserved.


 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire