Java Code Examples for com.gargoylesoftware.htmlunit.WebClient#openDialogWindow()

The following examples show how to use com.gargoylesoftware.htmlunit.WebClient#openDialogWindow() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Window.java    From htmlunit with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a modal dialog box that displays the specified HTML document.
 * @param url the URL of the document to load and display
 * @param arguments object to be made available via <tt>window.dialogArguments</tt> in the dialog window
 * @param features string that specifies the window ornaments for the dialog window
 * @return the value of the {@code returnValue} property as set by the modal dialog's window
 * @see <a href="http://msdn.microsoft.com/en-us/library/ms536759.aspx">MSDN Documentation</a>
 * @see <a href="https://developer.mozilla.org/en/DOM/window.showModalDialog">Mozilla Documentation</a>
 */
@JsxFunction(IE)
public Object showModalDialog(final String url, final Object arguments, final String features) {
    final WebWindow webWindow = getWebWindow();
    final WebClient client = webWindow.getWebClient();
    try {
        final URL completeUrl = ((HtmlPage) getDomNodeOrDie()).getFullyQualifiedUrl(url);
        final DialogWindow dialog = client.openDialogWindow(completeUrl, webWindow, arguments);
        // TODO: Theoretically, we shouldn't return until the dialog window has been close()'ed...
        // But we have to return so that the window can be close()'ed...
        // Maybe we can use Rhino's continuation support to save state and restart when
        // the dialog window is close()'ed? Would only work in interpreted mode, though.
        final ScriptableObject jsDialog = dialog.getScriptableObject();
        return jsDialog.get("returnValue", jsDialog);
    }
    catch (final IOException e) {
        throw Context.throwAsScriptRuntimeEx(e);
    }
}
 
Example 2
Source File: Window.java    From HtmlUnit-Android with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a modal dialog box that displays the specified HTML document.
 * @param url the URL of the document to load and display
 * @param arguments object to be made available via <tt>window.dialogArguments</tt> in the dialog window
 * @param features string that specifies the window ornaments for the dialog window
 * @return the value of the {@code returnValue} property as set by the modal dialog's window
 * @see <a href="http://msdn.microsoft.com/en-us/library/ms536759.aspx">MSDN Documentation</a>
 * @see <a href="https://developer.mozilla.org/en/DOM/window.showModalDialog">Mozilla Documentation</a>
 */
@JsxFunction({IE, FF})
public Object showModalDialog(final String url, final Object arguments, final String features) {
    final WebWindow webWindow = getWebWindow();
    final WebClient client = webWindow.getWebClient();
    try {
        final URL completeUrl = ((HtmlPage) getDomNodeOrDie()).getFullyQualifiedUrl(url);
        final DialogWindow dialog = client.openDialogWindow(completeUrl, webWindow, arguments);
        // TODO: Theoretically, we shouldn't return until the dialog window has been close()'ed...
        // But we have to return so that the window can be close()'ed...
        // Maybe we can use Rhino's continuation support to save state and restart when
        // the dialog window is close()'ed? Would only work in interpreted mode, though.
        final ScriptableObject jsDialog = dialog.getScriptableObject();
        return jsDialog.get("returnValue", jsDialog);
    }
    catch (final IOException e) {
        throw Context.throwAsScriptRuntimeEx(e);
    }
}
 
Example 3
Source File: Window.java    From htmlunit with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a modeless dialog box that displays the specified HTML document.
 * @param url the URL of the document to load and display
 * @param arguments object to be made available via <tt>window.dialogArguments</tt> in the dialog window
 * @param features string that specifies the window ornaments for the dialog window
 * @return a reference to the new window object created for the modeless dialog
 * @see <a href="http://msdn.microsoft.com/en-us/library/ms536761.aspx">MSDN Documentation</a>
 */
@JsxFunction(IE)
public Object showModelessDialog(final String url, final Object arguments, final String features) {
    final WebWindow webWindow = getWebWindow();
    final WebClient client = webWindow.getWebClient();
    try {
        final URL completeUrl = ((HtmlPage) getDomNodeOrDie()).getFullyQualifiedUrl(url);
        final DialogWindow dialog = client.openDialogWindow(completeUrl, webWindow, arguments);
        return dialog.getScriptableObject();
    }
    catch (final IOException e) {
        throw Context.throwAsScriptRuntimeEx(e);
    }
}
 
Example 4
Source File: Window.java    From HtmlUnit-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a modeless dialog box that displays the specified HTML document.
 * @param url the URL of the document to load and display
 * @param arguments object to be made available via <tt>window.dialogArguments</tt> in the dialog window
 * @param features string that specifies the window ornaments for the dialog window
 * @return a reference to the new window object created for the modeless dialog
 * @see <a href="http://msdn.microsoft.com/en-us/library/ms536761.aspx">MSDN Documentation</a>
 */
@JsxFunction(IE)
public Object showModelessDialog(final String url, final Object arguments, final String features) {
    final WebWindow webWindow = getWebWindow();
    final WebClient client = webWindow.getWebClient();
    try {
        final URL completeUrl = ((HtmlPage) getDomNodeOrDie()).getFullyQualifiedUrl(url);
        final DialogWindow dialog = client.openDialogWindow(completeUrl, webWindow, arguments);
        final Window jsDialog = (Window) dialog.getScriptableObject();
        return jsDialog;
    }
    catch (final IOException e) {
        throw Context.throwAsScriptRuntimeEx(e);
    }
}