Hi!
I am trying out the ChildBrowserSample-example.
First problem:
In the code I put a System.out.println() before and after the waitChild1()-call:
...
System.out.println("Before..");
// execute operation that opens child and get reference to the opened child (new method)
WebBrowser child = waitChild1(browser, element);
System.out.println("After..");
...
I wonder why the second System.out.println() is never reached?
Second problem:
Is the WebBrowser.trackChildren()-method deprecated? In the ChildBrowserSample-example it is only mentioned in the waitChild2()-method, which is described as the "old method".
Regards,
Jesper
Hi,
1. In our environment we have not to reproduce this problem. The second System.out.println() is always reached. Please make sure you are using the latest version of JExplorer - 1.6.
2. The WebBrowser.trackChildren() method is not deprecated. And the waitChild2() method it just an alternative way of creating and retrieving the child instance.
Hi Vladimir,
Thanks for your reply.
This is really strange. I have just downloaded the latest JExplorer - 1.6, but it doesn't solve the problem.
To be precise I run the following code:
package core;
/*
Copyright (c) 2002-2006 TeamDev Ltd. All rights reserved.
*
Use is subject to license terms.
*
The complete licence text can be found at
*/
import com.jniwrapper.win32.ie.Browser;
import com.jniwrapper.win32.ie.WebBrowser;
import com.jniwrapper.win32.ie.dom.HTMLElement;
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;
/**
This sample creates browser added to a Swing container and demonstrates how to handle NewWindow browser's event.
*
@author Serge Piletsky
*/
public class ChildBrowserSample
{
private static final String HTML_CONTENT =
"" + "" + "Open Google in another window. " + "";
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();
JOptionPane.showMessageDialog(frame, "Click link that opens child window.", "JExplorer", JOptionPane.INFORMATION_MESSAGE);
final HTMLElement element = (HTMLElement)browser.getDocument().getElementById("theLink");
// execute operation that opens child and get reference to the opened child (new method)
System.out.println("Before..");
WebBrowser child = waitChild1(browser, element);
System.out.println("After..");
/*
// execute operation that opens child and get reference to the opened child (old method)
WebBrowser child = waitChild2(browser, element);
*/
String childTitle = child.getDocument().getTitle();
JOptionPane.showMessageDialog(frame, "Child title: " + childTitle + ".", "JExplorer", JOptionPane.INFORMATION_MESSAGE);
}
private static WebBrowser waitChild1(WebBrowser browser, final HTMLElement element)
{
return browser.waitChildCreation(new Runnable()
{
public void run()
{
// click on link that opens popup window
element.click();
}
});
}
private static WebBrowser waitChild2(WebBrowser browser, final HTMLElement element)
{
// Start track child window creation
browser.trackChildren();
// click on link that opens popup window
element.click();
// get reference to popup window
return browser.waitChildCreation();
}
}
When the JFrame opens, I click the "OK"-button. The text "Before" is then written, and the small Google-window is opened as a child-window. I then close this child-window and finally the JFrame, but the text "After" is never written, and the remaining statements are never reached.
I am running:
- JExplorer 1.6
- JDK1.5.0_06
- IE6.0, SP 1 (all cookies deleted)
- no pop-up blocker enabled
Any idea how to get closer to the problem?
Regards,
Jesper
Hi again,
Just some further comments.
3. The following jars are used in this order:
- comfyj-2.1
- jexplorer-1.6
- jniwrap-3.1
- mshtml
- winpack-3.0
4. In the waitChild2()-method I have included a
System.out.println(browser.getRecentChild());
- before the
return browser.waitChildCreation();
- and the getRecentChild() always returns "null".
5. In the HTML_CONTENT-variable I have tried to replace the
href=\"javascript:openAnotherWindow()\"
- with
href=\"http://www.google.com\" target=\"_blank\"
- to omit javascript, if this caused the problem.
Regards,
Jesper
Hello,
I managed to reproduce this problem. It happens if the child window is closed before the content of the page is loaded.
So you need to wait until the content of the page is fully loaded (you should see the Message Dialog).
Hi again,
I have tried to wait for a while to let the child-window fully load. However the problem remains the same and the Message Dialog is never shown.
But when I close the child-window after some time and then the JFrame I get the following error:
"CiceroUIWndFrame .. The memory could not be written".
Searhing this "CiceroUIWndFrame"-error I found that it has to do with Office speech/handwriting recognition.
Do you have any idea, whether this explains the other problem?
Do you have Office installed?
Regards,
Jesper
Hi again,
One further comment.
I have now tried to run the ChildBrowserSample on both Windows XP and Windows 2000. The "CiceroUIWndFrame"-error only appears on XP, however the basic problem remains the same in both setups.
Regards,
Jesper
This error is not caused by JExplorer, but rather by Microsoft Office's Speech and Handwriting Recognition. In order to continue using JExplorer, you will need to disable this Microsoft feature.
To disable the Speech and Handwriting Recognition
1. Click "Start" button at the bottom left of Microsoft Windows.
2. Click "Control Panel."
3. Click "Add/Remove Programs."
4. Click "Microsoft Office."
5. Click on the "Change" button
6. Browse to "Office Shared Features."
7. Click on "Alternative User Input."
8. For both the Speech and Handwriting Recognition, select "Not available."
Once this is disabled, the CiceroUIWndFrame messages disappear. Also, please check this Microsoft support site for a more detailed set of steps to remove these tools:
http://support.microsoft.com/default.aspx?scid=kb;%5BLN%5D;326526
Hi again,
I have tried to run JExplorer 1.6 on a Windows 2000 computer without Office installed, and unfortunately the problem remains the same.
Any further ideas?
Regards,
Jesper
P.S.: Could some of the other users out there try and run the ChildBrowserSample-example to see if I am the only one with this problem?
Hi,
For receiving the newWindow events JExplorer 1.6 uses the DWebBrowserEvents2.NewWindow3 (http://msdn.microsoft.com/workshop/browser/webbrowser/reference/ifaces/dwebbrowserevents2/newwindow3.asp ) method instead the DWebBrowserEvents2.NewWindow2 (http://msdn.microsoft.com/workshop/browser/webbrowser/reference/ifaces/dwebbrowserevents2/newwindow2.asp ).
But the NewWindow3 is only available in Microsoft Windows XP Service Pack 2 (SP2) or later (http://msdn.microsoft.com/workshop/browser/webbrowser/reference/events/newwindow3.asp ).
So, if you use the Windows XP and in your environment the Service Pack 2 not installed, please do it.
Vladimir
Hi again Vladimir,
Thanks for your help, that explains it.
I don't think that IE 6.0 SP2 is available for Windows 2000 - at least not yet. Actually I am not familiar with the way these service packs for IE are numbered relative to the Windows-version.
What I am saying is that - at least the moment - JExplorer 1.6 will not work properly with Windows 2000, which I guess is a problem for many users (myself included) who prefer Windows 2000 to Windows XP.
You could of course consider making the JExplorer-code dependent of the actual service pack, but that could mean a lot of housekeeping inside JExplorer I guess.
In general however I think you should have these possible Windows 2000/XP-differences with respect to IE in mind in order not to limit the use of JExplorer.
Regards,
Jesper