public interface BrowserApplication
appService =servicesBroker
.getService
(ApplicationService
.class); browser =appService
.openApplication
(BrowserApplication
.TYPE, null).getApplication()
.getApplication()
; browser.openUrl
("www.e-spirit.de");
Example how to create a browser application |
Modifier and Type | Field and Description |
---|---|
static ApplicationType<BrowserApplication,BrowserApplicationConfiguration> |
TYPE
Application type to
open this browser application. |
Modifier and Type | Method and Description |
---|---|
void |
addBrowserListener(BrowserListener listener)
Adds the given
browser listener to be notified on browser change events. |
String |
convertToScript(Object object)
Converts specified java object into JavaScript code.
|
<T> BrowserNodeHandlerBuilder<T> |
createNodeHandlerBuilder()
Provides a builder for constructing and binding a
BrowserNodeHandler . |
Object |
evaluateScript(String script)
Executes given JavaScript code and evaluates return value.
|
Object |
evaluateScriptMethod(String methodIdentifier,
Object... arguments)
Generates JavaScript code for the specified JavaScript method call, executes it in currently opened document and
evaluates the return value of the method call.
|
void |
executeScript(String script)
Executes given JavaScript code in the currently opened document.
|
void |
executeScriptMethod(String methodIdentifier,
Object... arguments)
Generates JavaScript code for the specified JavaScript method call and executes it in currently opened document.
|
void |
focus()
Requests that the related browser component get the input focus.
|
Document |
getCurrentDocument()
Returns accessor for the document in the currently loaded page.
|
EngineType |
getEngineType()
Returns the type of the browser engine that is currently used by this BrowserApplication.
|
String |
getEngineVersion()
Returns the version string of the browser engine that is currently used by this BrowserApplication.
|
String |
getUrl()
Returns the url of this browser application or
null if no url requested yet. |
void |
inject(Object object,
String name)
Creates a javascript proxy for the given object instance.
|
void |
openUrl(String url)
Opens the given
url . |
void |
removeBrowserListener(BrowserListener listener)
Removes the given
browser listener . |
void |
saveTo(String url,
File file,
ProgressListener listener)
Requests the specified url and save content to specified file.
|
void |
setHtmlContent(String html)
Sets the specified HTML content to the current Browser document.
|
static final ApplicationType<BrowserApplication,BrowserApplicationConfiguration> TYPE
open
this browser application.
Example:
openApplication
(BrowserApplication.TYPE
, config).getApplication()
;
@Nullable String getEngineVersion()
EngineType getEngineType()
void openUrl(String url)
url
.browser listener
before
calling this method, if you need to be informed of the location change calling this method will lead to.url
- to openaddBrowserListener(BrowserListener)
@Nullable String getUrl()
null
if no url requested yet.browser listener
.null
if no url requested yet.addBrowserListener(BrowserListener)
void addBrowserListener(@NotNull BrowserListener listener)
browser listener
to be notified on browser change events.listener
- the listener to be notifiedremoveBrowserListener(BrowserListener)
void removeBrowserListener(@NotNull BrowserListener listener)
browser listener
.listener
- the listener to be removed.void saveTo(String url, File file, ProgressListener listener) throws IOException
url
- url to loadfile
- the target filelistener
- a listener for download progress or nullIOException
- when an error occurs during download processBrowser.saveTo(String,File,ProgressListener)
void focus()
Browser.focus()
void setHtmlContent(String html)
browser listener
.html
- a string that represents HTML content to set to the current document.Document getCurrentDocument()
Element
of the returned
document will also be of type BrowserNode
.completely
before calling this method.DocumentGoneException
will be thrown if the belonging nodes aren't accessible any more (e.g. cause browser navigated to a different url)BrowserNode
void executeScript(String script)
completely
before calling this method.script
- script code to executevoid executeScriptMethod(String methodIdentifier, Object... arguments)
completely
before calling this method.methodIdentifier
- method identifier (for example: "window.methodName")arguments
- arguments the javascript method should be called withexecuteScript(String)
@Nullable Object evaluateScript(String script)
completely
before calling this method.
JavaScript | Java |
---|---|
number | Double |
string | String |
boolean | Boolean |
array | List<Object> |
object | Map<String,Object> |
script
- script code to be executed@Nullable Object evaluateScriptMethod(String methodIdentifier, Object... arguments)
completely
before calling this method.methodIdentifier
- method identifier (for example: "window.methodName")arguments
- arguments the javascript method should be called withevaluateScript(String)
@Nullable String convertToScript(Object object)
Java | JavaScript |
---|---|
Number, Boolean | (related toString mechanism) |
String | "stringcontent"(escapes newline and ") |
List<Object> | [entry0,entry1,entry2,...] |
Map<String,Object> | {'key0':value0,'key1':value1,...} |
object
- javaobject that should be converted to JavaScript codevoid inject(Object object, String name)
completely
before calling this method.
public class Test {
public void call() {...}
public void set(String parameter) {...}
public String get() {...}
}
browserApp.inject(new Test(), "myTest");
window.myTest.call();
window.myTest.set("value");
window.Test.get(function(value){alert(value);});
evaluateScript(String)
the method parameters and return values are converted under
the same conversion pattern.Number
are equal in javascript and would be converted
to javascript type 'number'.object
- the object that should be injected into web pagename
- the name of the new javascript proxy object<T> BrowserNodeHandlerBuilder<T> createNodeHandlerBuilder()
BrowserNodeHandler
.Copyright © 2014 e-Spirit AG. All Rights Reserved. Build 5.0_BETA.500