|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
The WebBrowser defines the base web browser
interface and its various capabilities. This interface provides
functionality that allows working with WebBrowser Control.
close() method.
- Java component that implements this interface and can be
embedded in a Swing UI,
- UI-less implementation of this interface,
- an Automation-based browser component which
you can use without embedding in a Swing UI| Nested Class Summary | |
static class |
WebBrowser.Properties
Represents a set of event names that can be handled in the PropertyChangeListener listener. |
| Method Summary | |
void |
addBrowserWindowListener(BrowserWindowListener listener)
Adds window listener. |
void |
addDisposeListener(DisposeListener listener)
Registers the for the current Browser instance that will receive events when the current Browser instance is disposed. |
void |
addNavigationListener(NavigationEventListener listener)
Adds browser navigation event listener. |
void |
addNewWindowListener(NewWindowEventListener listener)
Adds new window listener. |
void |
addPropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener listener)
Adds a new property change listener. |
void |
addStatusListener(StatusEventListener listener)
Adds browser status event listener. |
void |
close()
Closes and disposes the current WebBrowser instance. |
void |
execute(BrowserCommand command)
Executes the specified WebBrowser command. |
java.lang.Object |
executeScript(java.lang.String javaScript)
Executes specified JavaScript code in a currently opened document. |
AuthenticationHandler |
getAuthenticationHandler()
Returns the current browser authentication handler or null if it's was not specified. |
java.lang.Object |
getBrowserPeer()
Returns an instance of the native WebBrowser peer as an instance of the IWebBrowser2 interface. |
java.lang.String |
getContent()
Returns the string that represents HTML content of a currently loaded document in WebBrowser. |
java.lang.String |
getContent(boolean original)
Returns the string that represents HTML content of a currently loaded document in WebBrowser. |
java.util.Set |
getCookies(java.lang.String url)
Deprecated. Use the CookieManager.getCookies(URL url) method instead. |
java.util.Set |
getCookies(java.net.URL url)
Returns cookies, that are associated with the specified URL. |
DialogEventHandler |
getDialogEventHandler()
Returns the dialog events handler or null if it's
was not specified. |
DisposeListener[] |
getDisposeListeners()
Returns an array of all registered listeners for the current Browser instance. |
HTMLDocument |
getDocument()
Returns an instance of HTMLDocument that
represents the HTML document currently loaded into
the WebBrowser and provides access to the contents of
the HTML Document Object Model (DOM). |
WebBrowserEventsHandler |
getEventHandler()
Returns browser event handler. |
HttpSecurityHandler |
getHttpSecurityHandler()
Returns http security handler that allows processing any security problems or null if it's not present. |
KeyFilter |
getKeyFilter()
Returns key filter. |
java.lang.String |
getLocationURL()
Returns the string that represents a URL of the resource that WebBrowser component is currently displayed. |
java.util.List |
getNavigationListeners()
Returns browser navigation event listeners. |
NewWindowEventHandler |
getNewWindowHandler()
Returns new window handler. |
java.util.List |
getNewWindowListeners()
Returns new window listeners. |
com.jniwrapper.win32.automation.OleMessageLoop |
getOleMessageLoop()
Returns the OleMessageLoop thread in which executes all WebBrowser component operations. |
WebBrowser |
getParentBrowser()
Returns the parent of the current WebBrowser instance or null if it hasn't parent. |
WebBrowser.Properties |
getProperties()
Returns extended browser properties. |
ProxyConfiguration |
getProxy()
Returns the proxy settings for the current WebBrowser control and all its children. |
ReadyState |
getReadyState()
Returns the current ReadyState of the WebBrowser Control. |
ScriptErrorListener |
getScriptErrorListener()
Returns script error listener for current page. |
java.util.List |
getStatusListeners()
Returns browser status event listeners. |
void |
goBack()
Navigates backward one item in the history list. |
void |
goForward()
Navigates forward one item in the history list. |
void |
goHome()
Navigates to the current home or start page. |
boolean |
isClosed()
Returns if the WebBrowser instance is closed and disposed. |
boolean |
isSilent()
Return true if alert, confirmation and error dialogs are disabled else returns false. |
void |
navigate(java.lang.String location)
Navigates to a resource identified by a URL or to a file identified by a full path. |
void |
navigate(java.lang.String location,
java.lang.String postData)
Navigates to a web resource specified by a HTTP URL with HTTP post data. |
void |
navigate(java.lang.String location,
java.lang.String targetName,
java.lang.String postData)
Navigates to an entire web resource specified by a HTTP URL with HTTP post data into a specified window defined by targetName. |
void |
refresh()
Reloads the file that is currently displayed in the object. |
void |
removeBrowserWindowListener(BrowserWindowListener listener)
Removes window listener. |
void |
removeDisposeListener(DisposeListener listener)
Removes the so that it will not receive events when the current Browser instance is disposed. |
void |
removeNavigationListener(NavigationEventListener listener)
Removes browser navigation event listener. |
void |
removeNewWindowListener(NewWindowEventListener listener)
Removes new window listener. |
void |
removePropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener listener)
Removes a specified property change listener. |
void |
removeStatusListener(StatusEventListener listener)
Removes browser status event listener. |
void |
setAuthenticationHandler(AuthenticationHandler handler)
Sets the specified browser authentication handler. |
void |
setContent(java.lang.String htmlContent)
Sets the specified HTML content to the current WebBrowser document. |
void |
setCookie(java.lang.String url,
Cookie cookie)
Deprecated. Use the CookieManager.setCookie(URL url, Cookie cookie) or
CookieManager.setCookies(URL url, Set cookies) methods instead. |
void |
setCookies(java.net.URL url,
java.util.Set cookies)
Creates a new cookies for the specified URL using WinINet API. |
void |
setDialogEventHandler(DialogEventHandler handler)
Sets the listener interface for receiving show dialog events. |
void |
setEventHandler(WebBrowserEventsHandler handler)
Sets browser event handler. |
void |
setHttpSecurityHandler(HttpSecurityHandler h)
Sets the specified HTTP security handler that allows processing any security problems such as Invalid Certificate error, Invalid Certificate Name, Invalid Certificate Date, Moving from a non-SSL to an SSL connection because of a redirect or The redirection requires user confirmation problems. |
void |
setKeyFilter(KeyFilter keyFilter)
Sets key filter. |
void |
setNewWindowHandler(NewWindowEventHandler newWindowHandler)
Sets new window handler. |
void |
setParentBrowser(WebBrowser webBrowser)
Deprecated. Will be removed because WebBrowser instance will receive parent automatically. |
void |
setProxy(ProxyConfiguration conf)
Sets the specified proxy settings for the current WebBrowser control and all its children. |
void |
setScriptErrorListener(ScriptErrorListener listener)
Setups javascript error listener for current page. |
void |
setSilent(boolean isSilent)
Disables or enables alert, confirmation and error dialogs. |
void |
stop()
Cancels any pending navigation or download operation and stops any dynamic page elements, such as background sounds and animations. |
void |
waitReady()
Deprecated. Use the NavigationEventListener.entireDocumentCompleted event
to make sure that the document is loaded completely. |
void |
waitReady(long timeout)
Deprecated. Use the NavigationEventListener.entireDocumentCompleted event
to make sure that the document is loaded completely. |
| Methods inherited from interface com.jniwrapper.win32.ie.ParentWindow |
getRecentChild, trackChildren, waitChildCreation, waitChildCreation |
| Method Detail |
public void navigate(java.lang.String location)
location - the URL of the resource to display or
the full path to the file location. The
parameter cannot be null.
java.lang.IllegalArgumentException - when location parameter is null.
java.lang.IllegalStateException - when WebBrowser component was
disposed by invoking WebBrowser.close()
method or for some unknown reasons.navigate(String, String),
navigate(String, String, String),
NavigationEventListener.entireDocumentCompleted(WebBrowser, String)
public void navigate(java.lang.String location,
java.lang.String postData)
location - the URL of the resource to display or
the full path to the file location. The
parameter cannot be null.postData - HTTP post data (for example, "name=Alex&product=Pizza"),
can be null.
java.lang.IllegalArgumentException - when location parameter is null.
java.lang.IllegalStateException - when WebBrowser component was
disposed by invoking WebBrowser.close()
method or for some unknown reasons.navigate(String),
navigate(String, String, String),
NavigationEventListener.entireDocumentCompleted(WebBrowser, String)
public void navigate(java.lang.String location,
java.lang.String targetName,
java.lang.String postData)
location - the URL of the resource to display or
the full path to the file location. The
parameter cannot be null.targetName - The string that contains the name of the
frame in which to display the resource.
The possible values for this parameter are.
postData - HTTP post data (for example, "name=Alex&product=Pizza").
java.lang.IllegalStateException - when WebBrowser component was
disposed by invoking WebBrowser.close()
method or for some unknown reasons.navigate(String),
navigate(String, String),
NavigationEventListener.entireDocumentCompleted(WebBrowser, String)public java.lang.String getLocationURL()
java.lang.IllegalStateException - when WebBrowser component was
disposed by invoking WebBrowser.close()
method or for some unknown reasons.NavigationEventListener.entireDocumentCompleted(WebBrowser, String)public HTMLDocument getDocument()
HTMLDocument that
represents the HTML document currently loaded into
the WebBrowser and provides access to the contents of
the HTML Document Object Model (DOM).
Before receiving an instance of HTMLDocument
make sure that the entire document is loaded completely.
For this you can use the
NavigationEventListener.entireDocumentCompleted(WebBrowser, String)
event.
java.lang.IllegalStateException - when WebBrowser.waitReady()
method isn't called after last call of
WebBrowser.navigate() or
WebBrowser.setContent() methods;
or when WebBrowser component was
disposed by invoking WebBrowser.close()
method or for some unknown reasons.HTMLDocument,
waitReady(),
navigate(String),
setContent(String),
NavigationEventListener.entireDocumentCompleted(WebBrowser, String)public WebBrowser getParentBrowser()
null if it hasn't parent. If the WebBrowser
control is in a frame, this method returns the WebBrowser
instance of the main document that contains this frame.
Otherwise, it delegates to the top-level WebBrowser control,
if there is one.
null
if the browser hasn't parent.Browser.getParentBrowser(),
HeadlessBrowser.getParentBrowser(),
IEAutomation.getParentBrowser()public void setParentBrowser(WebBrowser webBrowser)
webBrowser - the parent of the browser.public void goForward()
StatusEventListener.forwardButtonEnabled
event to check the enabled state of forward navigation.
To manage WebBrowser's history use the BrowserHistory class.
java.lang.IllegalStateException - when WebBrowser component was
disposed by invoking WebBrowser.close()
method or for some unknown reasons.goBack(),
goHome(),
BrowserHistorypublic void goBack()
StatusEventListener.backButtonEnabled
event to check the enabled state of back navigation.
To manage WebBrowser's history use the BrowserHistory class.
java.lang.IllegalStateException - when WebBrowser component was
disposed by invoking WebBrowser.close()
method or for some unknown reasons.goForward(),
goHome(),
BrowserHistorypublic void goHome()
java.lang.IllegalStateException - when WebBrowser component was
disposed by invoking WebBrowser.close()
method or for some unknown reasons.goForward(),
goBack()public void stop()
java.lang.IllegalStateException - when WebBrowser component was
disposed by invoking WebBrowser.close()
method or for some unknown reasons.refresh(),
navigate(String),
NavigationEventListener.entireDocumentCompleted(WebBrowser, String)public void refresh()
java.lang.IllegalStateException - when WebBrowser component was
disposed by invoking WebBrowser.close()
method or for some unknown reasons.public void execute(BrowserCommand command)
BrowserCommand abstract class.
For example, to print currently loaded web page, the following
command should be executed:
WebBrowser browser = new HeadlessBrowser();
browser.execute(new PrintCommand());
command - the specified WebBrowser command.
java.lang.IllegalStateException - when WebBrowser component was
disposed by invoking WebBrowser.close()
method or for some unknown reasons.PrintCommand,
PrintPreviewCommand,
SaveAsCommandpublic void setContent(java.lang.String htmlContent)
NavigationEventListener.entireDocumentCompleted event.
It may be necessary when the document contains some resources
(such as images or JavaScript files) that require some time to
download.
htmlContent - a string that represents HTML content
to set to the current document.
java.lang.IllegalStateException - when WebBrowser component was
disposed by invoking WebBrowser.close()
method or for some unknown reasons.navigate(String),
navigate(String, String),
navigate(String, String, String),
getContent(),
getContent(boolean),
NavigationEventListener.entireDocumentCompleted(WebBrowser, String)public java.lang.String getContent()
NavigationEventListener.entireDocumentCompleted event.
Note: the outerHTML propertry of the document HTML element
is used in this method. So, it always returns the actual HTML of
the document. To get the HTML that was downloaded from the server
use the getContent(true) method.
java.lang.IllegalStateException - when WebBrowser component was
disposed by invoking WebBrowser.close()
method or for some unknown reasons.setContent(String),
getContent(boolean),
NavigationEventListener.entireDocumentCompleted(WebBrowser, String)public java.lang.String getContent(boolean original)
NavigationEventListener.entireDocumentCompleted event.
original - if true then returns the original
HTML content (like View Source command in context
menu of Internet Explorer browser), otherwise this method
returns the actual content of a document according to its DOM.
java.lang.IllegalStateException - when WebBrowser component was
disposed by invoking WebBrowser.close()
method or for some unknown reasons.getContent(),
setContent(String),
NavigationEventListener.entireDocumentCompleted(WebBrowser, String)public java.lang.Object executeScript(java.lang.String javaScript)
IHTMLWindow2.execScript method
can access all global variables available to the calling script.
javaScript - the string that specifies the code to be executed.
java.lang.IllegalStateException - when WebBrowser component was
disposed by invoking WebBrowser.close()
method or for some unknown reasons.public ReadyState getReadyState()
ReadyState of the WebBrowser Control.
java.lang.IllegalStateException - when WebBrowser component was
disposed by invoking WebBrowser.close()
method or for some unknown reasons.
public void addPropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener listener)
WebBrowser.Properties class.
propertyName - property name.listener - listener instance.
public void removePropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener listener)
WebBrowser.Properties class.
propertyName - property name.listener - listener instance.public void waitReady()
NavigationEventListener.entireDocumentCompleted event
to make sure that the document is loaded completely.
Important: successful call of this method guaranties that you
can get DOM document of loaded page.
Please see typical usage of this method in the code below:
// navigate to Google page
browser.navigate("google.com");
// wait until page completely loaded
browser.waitReady();
// DOM document is available
Document document = browser.getDocument();
WebBrowser.waitReady() call after navigation call
then IllegalStateException is thrown in WebBrowser.getDocument() call.
java.lang.IllegalStateException - when WebBrowser component was
disposed by invoking WebBrowser.close()
method or for some unknown reasons.navigate(String),
setContent(String),
getDocument()public void waitReady(long timeout)
NavigationEventListener.entireDocumentCompleted event
to make sure that the document is loaded completely.
timeout - the number of milliseconds to wait.
java.lang.IllegalStateException - when WebBrowser component was
disposed by invoking WebBrowser.close()
method or for some unknown reasons.public java.lang.Object getBrowserPeer()
IWebBrowser2 interface. The
returned value can be casted to IWebBrowser2
interface.
java.lang.IllegalStateException - when the passed browser does not have
a native peer or WebBrowser component was
disposed by invoking WebBrowser.close()
method or for some unknown reasons.public void addNavigationListener(NavigationEventListener listener)
listener - browser event listener.public void removeNavigationListener(NavigationEventListener listener)
listener - browser event listener.public java.util.List getNavigationListeners()
public void addStatusListener(StatusEventListener listener)
listener - browser event listener.public void removeStatusListener(StatusEventListener listener)
listener - browser event listener.public java.util.List getStatusListeners()
public void setEventHandler(WebBrowserEventsHandler handler)
handler - event handlerpublic WebBrowserEventsHandler getEventHandler()
public void setAuthenticationHandler(AuthenticationHandler handler)
handler - the authentication handler
java.lang.IllegalStateException - when WebBrowser component was
disposed by invoking WebBrowser.close()
method or for some unknown reasons.getAuthenticationHandler()public AuthenticationHandler getAuthenticationHandler()
null if it's was not specified. The
authentication handler allows handling the authenticate
events from the browser object. Currently supported the
basic, digest and NTLM authentication schemes.
By default this method always returns null.
null.
java.lang.IllegalStateException - when WebBrowser component was
disposed by invoking WebBrowser.close()
method or for some unknown reasons.setAuthenticationHandler(AuthenticationHandler)public void setDialogEventHandler(DialogEventHandler handler)
DialogEventHandler. Please see the
Browser.setDialogEventHandler(com.jniwrapper.win32.ie.event.DialogEventHandler) and
HeadlessBrowser.setDialogEventHandler(com.jniwrapper.win32.ie.event.DialogEventHandler) method.
handler - dialog event handler
java.lang.IllegalStateException - when WebBrowser component was
disposed by invoking WebBrowser.close()
method or for some unknown reasons.getDialogEventHandler(),
setSilent(boolean),
isSilent(),
Browser.setDialogEventHandler(com.jniwrapper.win32.ie.event.DialogEventHandler),
HeadlessBrowser.setDialogEventHandler(com.jniwrapper.win32.ie.event.DialogEventHandler)public DialogEventHandler getDialogEventHandler()
null if it's
was not specified.
By default this method returns the default implementation of
the DialogEventHandler which is different for each
implementation of the WebBrowser interface.
Please see the Browser.getDialogEventHandler() and
HeadlessBrowser.getDialogEventHandler() method.
null if it's
was not specified.
java.lang.IllegalStateException - when WebBrowser component was
disposed by invoking WebBrowser.close()
method or for some unknown reasons.setDialogEventHandler(DialogEventHandler),
setSilent(boolean),
isSilent(),
Browser.getDialogEventHandler(),
HeadlessBrowser.getDialogEventHandler()public void setScriptErrorListener(ScriptErrorListener listener)
listener - javascript error listenerpublic ScriptErrorListener getScriptErrorListener()
public void close()
isClosed()public boolean isClosed()
close()public void setSilent(boolean isSilent)
This method call modifies dialog event handler through
setDialogEventHandler() call.
isSilent - if true then enter to silent mode else leave silent mode.public boolean isSilent()
public void setCookie(java.lang.String url,
Cookie cookie)
CookieManager.setCookie(URL url, Cookie cookie) or
CookieManager.setCookies(URL url, Set cookies) methods instead.
InternetSetCookie native function.
url - specifies an URL, a new cookie will be associated with.cookie - specifies a new cookie.public java.util.Set getCookies(java.lang.String url)
CookieManager.getCookies(URL url) method instead.
InternetGetCookie native function.
url - specifies an URL.
public void setNewWindowHandler(NewWindowEventHandler newWindowHandler)
newWindowHandler - new window handlerpublic NewWindowEventHandler getNewWindowHandler()
public void addNewWindowListener(NewWindowEventListener listener)
listener - new window listenerpublic void removeNewWindowListener(NewWindowEventListener listener)
listener - new window listenerpublic java.util.List getNewWindowListeners()
public void setKeyFilter(KeyFilter keyFilter)
keyFilter - key filterpublic KeyFilter getKeyFilter()
public WebBrowser.Properties getProperties()
public void addBrowserWindowListener(BrowserWindowListener listener)
listener - the window listenerpublic void removeBrowserWindowListener(BrowserWindowListener listener)
listener - the window listenerpublic com.jniwrapper.win32.automation.OleMessageLoop getOleMessageLoop()
public void setProxy(ProxyConfiguration conf)
Browsers.setProxy(ProxyConfiguration)
method.
conf - the proxy settings. This parameter cannot be
null.
java.lang.IllegalStateException - when the passed browser does not have
a native peer or WebBrowser component was
disposed by invoking WebBrowser.close()
method or for some unknown reasons.getProxy(),
Browsers.setProxy(ProxyConfiguration)public ProxyConfiguration getProxy()
Browsers.getProxy() method.
java.lang.IllegalStateException - when the passed browser does not have
a native peer or WebBrowser component was
disposed by invoking WebBrowser.close()
method or for some unknown reasons.setProxy(ProxyConfiguration),
Browsers.getProxy()public java.util.Set getCookies(java.net.URL url)
It checks in the windows\cookies directory for persistent cookies that have an expiration date set sometime in the future.
It also searches memory for any session cookies, that is, cookies that do not have an expiration date that were created in the same process by CookieManager.setCookie(), because these cookies are not written to any files. Rules for creating cookie files are internal to the system and can change in the future.
Note: The method does not return cookies that the server marked as non-scriptable with the "HttpOnly" attribute in the Set-Cookie header.
url - specifies an URL.
public void setCookies(java.net.URL url,
java.util.Set cookies)
Cookies created by this method without an expiration date are stored in memory and are available only in the same process that created them. Cookies that include an expiration date are stored in the windows\cookies directory.
url - specifies an URL, a new cookie will be associated with.cookies - the collection of Cookie objects.public void setHttpSecurityHandler(HttpSecurityHandler h)
h - the specified HTTP security handler.
java.lang.IllegalStateException - when the passed browser does not have
a native peer or WebBrowser component was
disposed by invoking WebBrowser.close()
method or for some unknown reasons.getHttpSecurityHandler()public HttpSecurityHandler getHttpSecurityHandler()
null if it's not present. By default this
method always returns null and all security problems are
processing by default Internet Explorer security handler.
null if it's not present
java.lang.IllegalStateException - when the passed browser does not have
a native peer or WebBrowser component was
disposed by invoking WebBrowser.close()
method or for some unknown reasons.setHttpSecurityHandler(com.jniwrapper.win32.ie.event.HttpSecurityHandler)public void addDisposeListener(DisposeListener listener)
listener - the listener to receive browser dispose events.public void removeDisposeListener(DisposeListener listener)
listener - the listener to remove.public DisposeListener[] getDisposeListeners()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||