/** * Sets the hash portion of the location URL (the portion following the '#'). * * @param oldURL the old URL * @param hash the new hash portion of the location URL */ public void setHash(final String oldURL, String hash) { // IMPORTANT: This method must not call setUrl(), because // we must not hit the server just to change the hash! if (hash != null && !hash.isEmpty() && hash.charAt(0) == '#') { hash = hash.substring(1); } final boolean hasChanged = hash != null && !hash.equals(hash_); hash_ = hash; final String newURL = getHref(); if (hasChanged) { final Window w = getWindow(); final Event event; if (getBrowserVersion().hasFeature(EVENT_TYPE_HASHCHANGEEVENT)) { event = new HashChangeEvent(w, Event.TYPE_HASH_CHANGE, oldURL, newURL); } else { event = new Event(w, Event.TYPE_HASH_CHANGE); event.initEvent(Event.TYPE_HASH_CHANGE, false, false); } w.executeEventLocally(event); } }
/** * Sets the hash portion of the location URL (the portion following the '#'). * * @param oldURL the old URL * @param hash the new hash portion of the location URL */ public void setHash(final String oldURL, String hash) { // IMPORTANT: This method must not call setUrl(), because // we must not hit the server just to change the hash! if (hash != null && !hash.isEmpty() && hash.charAt(0) == '#') { hash = hash.substring(1); } final boolean hasChanged = hash != null && !hash.equals(hash_); hash_ = hash; final String newURL = getHref(); if (hasChanged) { final Window w = getWindow(); final Event event; if (getBrowserVersion().hasFeature(EVENT_TYPE_HASHCHANGEEVENT)) { event = new HashChangeEvent(w, Event.TYPE_HASH_CHANGE, oldURL, newURL); } else { event = new Event(w, Event.TYPE_HASH_CHANGE); event.initEvent(Event.TYPE_HASH_CHANGE, false, false); } w.executeEventLocally(event); } }
public void execute() throws Exception { if (newLocation.startsWith(JAVASCRIPT_PREFIX)) { final String script = newLocation.substring(11); page.executeJavaScriptIfPossible(script, "new location value", 1); return; } try { final URL url = page.getFullyQualifiedUrl(newLocation); final URL oldUrl = page.getWebResponse().getRequestSettings().getUrl(); if (url.sameFile(oldUrl) && !StringUtils.equals(url.getRef(), oldUrl.getRef())) { // If we're just setting or modifying the hash, avoid a server hit. jsxSet_hash(newLocation); return; } final WebWindow webWindow = getWindow().getWebWindow(); webWindow.getWebClient().getPage(webWindow, new WebRequestSettings(url)); } catch (final MalformedURLException e) { LOG.error("jsxSet_location('" + newLocation + "') Got MalformedURLException", e); throw e; } catch (final IOException e) { LOG.error("jsxSet_location('" + newLocation + "') Got IOException", e); throw e; } } };
public void execute() throws Exception { if (newLocation.startsWith(JAVASCRIPT_PREFIX)) { final String script = newLocation.substring(11); page.executeJavaScriptIfPossible(script, "new location value", 1); return; } try { final URL url = page.getFullyQualifiedUrl(newLocation); final URL oldUrl = page.getWebResponse().getRequestSettings().getUrl(); if (url.sameFile(oldUrl) && !StringUtils.equals(url.getRef(), oldUrl.getRef())) { // If we're just setting or modifying the hash, avoid a server hit. jsxSet_hash(newLocation); return; } final WebWindow webWindow = getWindow().getWebWindow(); webWindow.getWebClient().getPage(webWindow, new WebRequestSettings(url)); } catch (final MalformedURLException e) { LOG.error("jsxSet_location('" + newLocation + "') Got MalformedURLException", e); throw e; } catch (final IOException e) { LOG.error("jsxSet_location('" + newLocation + "') Got IOException", e); throw e; } } };
public void execute() throws Exception { if (newLocation.startsWith(JAVASCRIPT_PREFIX)) { final String script = newLocation.substring(11); page.executeJavaScriptIfPossible(script, "new location value", 1); return; } try { final URL url = page.getFullyQualifiedUrl(newLocation); final URL oldUrl = page.getWebResponse().getRequestSettings().getUrl(); if (url.sameFile(oldUrl) && !StringUtils.equals(url.getRef(), oldUrl.getRef())) { // If we're just setting or modifying the hash, avoid a server hit. jsxSet_hash(newLocation); return; } final WebWindow webWindow = getWindow().getWebWindow(); webWindow.getWebClient().getPage(webWindow, new WebRequestSettings(url)); } catch (final MalformedURLException e) { LOG.error("jsxSet_location('" + newLocation + "') Got MalformedURLException", e); throw e; } catch (final IOException e) { LOG.error("jsxSet_location('" + newLocation + "') Got IOException", e); throw e; } } };
final HtmlPage page = (HtmlPage) getWindow(getStartingScope()).getWebWindow().getEnclosedPage(); if (newLocation.startsWith(JavaScriptURLConnection.JAVASCRIPT_PREFIX)) { final String script = newLocation.substring(11);
final HtmlPage page = (HtmlPage) getWindow(getStartingScope()).getWebWindow().getEnclosedPage(); if (newLocation.startsWith(JavaScriptURLConnection.JAVASCRIPT_PREFIX)) { final String script = newLocation.substring(11);
/** * Reloads the current page, possibly forcing retrieval from the server even if * the browser cache contains the latest version of the document. * @param force if {@code true}, force reload from server; otherwise, may reload from cache * @throws IOException if there is a problem reloading the page * @see <a href="http://msdn.microsoft.com/en-us/library/ms536342.aspx">MSDN Documentation</a> */ @JsxFunction public void reload(final boolean force) throws IOException { final HtmlPage htmlPage = (HtmlPage) getWindow(getStartingScope()).getWebWindow().getEnclosedPage(); final WebRequest request = htmlPage.getWebResponse().getWebRequest(); String referer = htmlPage.getUrl().toExternalForm(); request.setAdditionalHeader(HttpHeader.REFERER, referer); referer = UrlUtils.getUrlWithNewQuery(htmlPage.getUrl(), null).toExternalForm(); referer = StringUtils.stripEnd(referer, "/"); request.setAdditionalHeader(HttpHeader.ORIGIN, referer); final WebWindow webWindow = window_.getWebWindow(); webWindow.getWebClient().download(webWindow, "", request, true, false, "JS location.reload"); }
/** * Reloads the current page, possibly forcing retrieval from the server even if * the browser cache contains the latest version of the document. * @param force if {@code true}, force reload from server; otherwise, may reload from cache * @throws IOException if there is a problem reloading the page * @see <a href="http://msdn.microsoft.com/en-us/library/ms536342.aspx">MSDN Documentation</a> */ @JsxFunction public void reload(final boolean force) throws IOException { final HtmlPage htmlPage = (HtmlPage) getWindow(getStartingScope()).getWebWindow().getEnclosedPage(); final WebRequest request = htmlPage.getWebResponse().getWebRequest(); String referer = htmlPage.getUrl().toExternalForm(); request.setAdditionalHeader(HttpHeader.REFERER, referer); referer = UrlUtils.getUrlWithNewQuery(htmlPage.getUrl(), null).toExternalForm(); referer = StringUtils.stripEnd(referer, "/"); request.setAdditionalHeader(HttpHeader.ORIGIN, referer); final WebWindow webWindow = window_.getWebWindow(); webWindow.getWebClient().download(webWindow, "", request, true, false, "JS location.reload"); }
final HtmlPage page = (HtmlPage) getWindow(getStartingScope()).getWebWindow().getEnclosedPage(); final PostponedAction action = new PostponedAction() {
final HtmlPage page = (HtmlPage) getWindow(getStartingScope()).getWebWindow().getEnclosedPage(); final PostponedAction action = new PostponedAction() {
final HtmlPage page = (HtmlPage) getWindow(getStartingScope()).getWebWindow().getEnclosedPage(); final PostponedAction action = new PostponedAction() {