Package com.teamdev.jxbrowser.navigation
Interface Navigation
- All Superinterfaces:
Advisable<NavigationCallback>
,Observable<NavigationEvent>
Allows loading resources in the browser instance and working with the navigation history.
-
Method Summary
Modifier and TypeMethodDescriptionbrowser()
Returns theBrowser
instance of this navigation.boolean
Indicates whether the previous location can be loaded.boolean
Indicates whether the next location can be loaded.int
Returns the index of the current item in the back-forward list or -1 if the list is empty.static Duration
Returns the default navigation timeout in seconds.entryAtIndex
(int index) Returns anOptional
that contains theNavigationEntry
instance for the givenindex
in the back-forward list, otherwise an emptyOptional
.int
Returns the number of items in the back-forward list.void
goBack()
Loads the previous location in the back-forward list.void
Loads the next location in the back-forward list.void
goToIndex
(int index) Navigates to a specific location at the givenindex
from the back-forward list.boolean
Returnstrue
if any of the browser frames is in the process of loading a document.void
loadUrl
(LoadUrlParams params) Navigates to the resource identified by the givenparams
.void
Navigates to the resource identified by the givenurl
.void
loadUrlAndWait
(LoadUrlParams params) Loads the resource identified by the givenparams
and blocks the current thread execution until the main frame of the resource is loaded completely or thedefaultTimeout()
is reached.void
loadUrlAndWait
(LoadUrlParams params, Duration timeout) Loads a resource identified by the givenparams
and blocks the current thread execution until the main frame of the resource is loaded completely or the giventimeout
is reached.void
loadUrlAndWait
(String url) Loads the resource identified by the givenurl
and blocks the current thread execution until the main frame of the resource is loaded completely or thedefaultTimeout()
is reached.void
loadUrlAndWait
(String url, Duration timeout) Loads the resource identified by the givenurl
and blocks the current thread execution until the main frame of the resource is loaded completely or the giventimeout
is reached.void
reload()
Reloads the currently loaded web page.void
Reloads the currently loaded web page, but if the current web page has POST data, the user is prompted to see if they really want to reload the page.void
Reloads the currently loaded web page ignoring caches.void
Reloads the currently loaded web page ignoring caches, but if the current web page has POST data, the user is prompted to see if they really want to reload the page.boolean
removeEntryAtIndex
(int index) Removes the item at the givenindex
in the back-forward list and returnstrue
if it was removed successfully.void
stop()
Cancels any pending navigation or download operation and stops any dynamic page elements, such as background sounds and animations.Methods inherited from interface com.teamdev.jxbrowser.event.Observable
on
-
Method Details
-
defaultTimeout
Returns the default navigation timeout in seconds. By default, the timeout equals 45 seconds. This value can be overridden via thejxbrowser.navigation.timeout.seconds
system property.- Since:
- 7.31
-
browser
Browser browser()Returns theBrowser
instance of this navigation. -
loadUrl
Navigates to the resource identified by the givenurl
. This method tells the browser to start asynchronous loading and returns immediately.- Parameters:
url
- the URL of the resource to load- Throws:
IllegalArgumentException
- when theurl
is empty or blankObjectClosedException
- when the browser is already closed
-
loadUrlAndWait
Loads the resource identified by the givenurl
and blocks the current thread execution until the main frame of the resource is loaded completely or thedefaultTimeout()
is reached.- Parameters:
url
- the URL of the resource to load- Throws:
IllegalArgumentException
- when theurl
is empty or blankTimeoutException
- when the resource hasn't been loaded within thedefaultTimeout()
NavigationException
- when the navigation failedObjectClosedException
- when the browser is already closed
-
loadUrlAndWait
Loads the resource identified by the givenurl
and blocks the current thread execution until the main frame of the resource is loaded completely or the giventimeout
is reached.- Parameters:
url
- the URL of the resource to loadtimeout
- the maximum time to wait for the navigation to complete- Throws:
IllegalArgumentException
- when theurl
is empty or blankIllegalArgumentException
- when thetimeout
is 0 or negativeTimeoutException
- when the resource hasn't been loaded within a timeoutNavigationException
- when the navigation failedObjectClosedException
- when the browser is already closed- Since:
- 7.9
-
isLoading
boolean isLoading()Returnstrue
if any of the browser frames is in the process of loading a document.- Throws:
ObjectClosedException
- when the browser is already closed
-
goBack
void goBack()Loads the previous location in the back-forward list. It does nothing if there is no previous location in the list.- Throws:
ObjectClosedException
- when the browser is already closed
-
canGoBack
boolean canGoBack()Indicates whether the previous location can be loaded.- Returns:
true
if the previous location in the back-forward list can be loaded- Throws:
ObjectClosedException
- when the browser is already closed
-
goForward
void goForward()Loads the next location in the back-forward list. It does nothing if there is no next location in the list.- Throws:
ObjectClosedException
- when the browser is already closed
-
canGoForward
boolean canGoForward()Indicates whether the next location can be loaded.- Returns:
true
if the next location in the back-forward list can be loaded- Throws:
ObjectClosedException
- when the browser is already closed
-
stop
void stop()Cancels any pending navigation or download operation and stops any dynamic page elements, such as background sounds and animations.- Throws:
ObjectClosedException
- when the browser is already closed
-
reload
void reload()Reloads the currently loaded web page.- Throws:
ObjectClosedException
- when the browser is already closed
-
reloadAndCheckForRepost
void reloadAndCheckForRepost()Reloads the currently loaded web page, but if the current web page has POST data, the user is prompted to see if they really want to reload the page.- Throws:
ObjectClosedException
- when the browser is already closed- See Also:
-
reloadIgnoringCache
void reloadIgnoringCache()Reloads the currently loaded web page ignoring caches.- Throws:
ObjectClosedException
- when the browser is already closed
-
reloadIgnoringCacheAndCheckForRepost
void reloadIgnoringCacheAndCheckForRepost()Reloads the currently loaded web page ignoring caches, but if the current web page has POST data, the user is prompted to see if they really want to reload the page.- Throws:
ObjectClosedException
- when the browser is already closed- See Also:
-
goToIndex
void goToIndex(int index) Navigates to a specific location at the givenindex
from the back-forward list.- Parameters:
index
- location of the item in the back-forward list- Throws:
IllegalArgumentException
- whenindex
is less than 0IllegalArgumentException
- whenindex
is more than the number of items in the back-forward listObjectClosedException
- when the browser is already closed- See Also:
-
entryCount
int entryCount()Returns the number of items in the back-forward list.- Throws:
ObjectClosedException
- when the browser is already closed
-
currentEntryIndex
int currentEntryIndex()Returns the index of the current item in the back-forward list or -1 if the list is empty.- Throws:
ObjectClosedException
- when the browser is already closed
-
entryAtIndex
Returns anOptional
that contains theNavigationEntry
instance for the givenindex
in the back-forward list, otherwise an emptyOptional
.- Parameters:
index
- location of the item to return in the back-forward list- Throws:
IllegalArgumentException
- whenindex
is less than 0IllegalArgumentException
- whenindex
is more than the number of items in the back-forward listObjectClosedException
- when the browser is already closed
-
removeEntryAtIndex
boolean removeEntryAtIndex(int index) Removes the item at the givenindex
in the back-forward list and returnstrue
if it was removed successfully.- Parameters:
index
- location of the item to remove in the back-forward list- Returns:
true
if the item was removed successfully- Throws:
IllegalArgumentException
- whenindex
is less than 0IllegalArgumentException
- whenindex
points to the current item in the back-forward listIllegalArgumentException
- whenindex
is more than the number of items in the back-forward listObjectClosedException
- when the browser is already closed
-