Hi All,
I am facing very peculiar problem with jexlorer dialogs/alerts. I have the code to handle the dialogs, which doesn't require
manual click on the dialog buttons. But the code works fine in one machine and doesn't work in the other. Both the
machines have windows xp professional installed with service pack 2. But only difference is, both the machines are
in different networks. I am using jexplorer 7.1. Tried the code even with jexplorer 8, but dialogs issue still remains.
I have pasted the code below to handle dialogs for reference.
Let me know what might be the problem for this different behaviors on different boxes.
Sample code.....
import com.jniwrapper.win32.ie.Browser;
import com.jniwrapper.win32.ie.WebBrowser;
import com.jniwrapper.win32.ie.event.BrowserDialogEventHandler;
import com.jniwrapper.win32.ie.dom.HTMLElement;
import com.jniwrapper.win32.ui.MessageBox;
import com.jniwrapper.win32.ui.Wnd;
import com.sun.java.swing.plaf.windows.WindowsLookAndFeel;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.UIManager;
import java.awt.BorderLayout;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
public class AlertHandlingSample
{
private static final String HTML_CONTENT =
"" + "";
public static void main(String[] args) throws Exception
{
UIManager.setLookAndFeel(WindowsLookAndFeel.class.getName());
JFrame frame = new JFrame("JExplorer - Child Browser Sample");
frame.setSize(800, 600);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLocationRelativeTo(null);
Browser browser = new Browser();
browser.setContent(HTML_CONTENT);
JPanel panel = new JPanel();
// set layout
panel.setLayout(new BorderLayout());
panel.add(browser, BorderLayout.CENTER);
frame.getContentPane().add(panel);
frame.setVisible(true);
browser.waitReady();
//Code to handle the alert
//Comment this portion of code and test it and then uncommnet and test
/*browser.setDialogEventHandler(new BrowserDialogEventHandler()
{
public int showDialog(Wnd wnd, String title, String text, int type)
{
System.out.println("inside the method");
// clicks the OK button on the alert dialog
return MessageBox.IDOK;
}
});*/
final HTMLElement element = (HTMLElement)browser.getDocument().getElementById("theLink");
element.click();
}
}
Thanks in advance.
Suvarna