Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » SWT Browser problem(SWT Browser problem with IE 6.0)
SWT Browser problem [message #522982] Wed, 24 March 2010 16:48 Go to next message
Manish Veerwal is currently offline Manish VeerwalFriend
Messages: 5
Registered: March 2010
Junior Member
Recently, I have been developing a application which opens a SWT browser to browse the customer details. My application takes input from the other application and opens swt browser as new thread.

As SWT browser uses IE for html rendering. It works fine with IE 7.0 or greater but with IE 6.0 it has some problem.

When i start my application, for first time swt browser works fine and shows the page for given URL but from second time it starts asking to open save or cancel the html page which IE has rendered. It saves the current URL in IE temp files and tries to open it from that location and asks if i want to open save or cancel. If i click open then it opens into IE browser not into SWT display. SWT display remains blank and i get my URL opened into IE which i do not want to happen.

Please can someone tell me what is going wrong?
Re: SWT Browser problem [message #523234 is a reply to message #522982] Thu, 25 March 2010 15:36 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2151
Registered: July 2009
Senior Member
I have not heard of this before. Are you able to provide some means of
reproducing the problem (eg.- a snippet like
http://www.eclipse.org/swt/faq.php#whatisasnippet , an example of an html
file that makes it happen, etc.)? To confirm, you're writing the content to
the file system and then Browser.setUrl(...) to it? You mention using
another thread, is the content definitely completely written before you try
to show it? Does navigating to this file repeatedly in stand-alone IE6 work
better?

Grant


"Manish Veerwal" <manish.veerwal@gmail.com> wrote in message
news:hodfpr$k9$1@build.eclipse.org...
> Recently, I have been developing a application which opens a SWT browser
to browse the customer details. My application takes input from the other
application and opens swt browser as new thread.
>
> As SWT browser uses IE for html rendering. It works fine with IE 7.0 or
greater but with IE 6.0 it has some problem.
>
> When i start my application, for first time swt browser works fine and
shows the page for given URL but from second time it starts asking to open
save or cancel the html page which IE has rendered. It saves the current URL
in IE temp files and tries to open it from that location and asks if i want
to open save or cancel. If i click open then it opens into IE browser not
into SWT display. SWT display remains blank and i get my URL opened into IE
which i do not want to happen.
>
> Please can someone tell me what is going wrong?
>
Re: SWT Browser problem [message #523383 is a reply to message #523234] Fri, 26 March 2010 09:19 Go to previous messageGo to next message
Manish Veerwal is currently offline Manish VeerwalFriend
Messages: 5
Registered: March 2010
Junior Member
My code for browser is as follows:

Display display = new Display();
Shell shell = new Shell(display, SWT.TITLE);
try {
InteractiveAlert interactiveAlert = (InteractiveAlert) session
.load(InteractiveAlert.class, alertID);
if (delay > 0) {
logger.debug("Interactive SWT Thread sleeping for " + delay);
Thread.sleep(delay);
updateStatus();
}
super.isOpen = true;
shell.setText(interactiveParameters.getFrameTitle());

Browser browser = new Browser(shell, SWT.NONE);
browser.addCloseWindowListener(new CloseWindowListener() {

public void close(WindowEvent arg0) {
closeBrowser = true;
}
});

if (interactiveParameters.isFullScreenMode()) {
Monitor monitor = shell.getMonitor();
Rectangle bounds = monitor.getBounds();
browser.setSize(bounds.width, bounds.height);
} else {
browser.setSize(interactiveParameters.getBrowser_width(),
interactiveParameters.getBrowser_height());
shell.setSize(interactiveParameters.getBrowser_width(),
interactiveParameters.getBrowser_height());
}

String url = createURL(interactiveAlert);
browser.setUrl(url);

if (interactiveParameters.isBeepEnabled()) {
// display.beep();
System.out.print("\007");
System.out.flush();
}
shell.open();
shell.setFullScreen(interactiveParameters.isFullScreenMode() );
shell.setMinimized(interactiveParameters.isMinimizedMode());
shell.forceActive();
shell.setActive();
while (!shell.isDisposed() && !closeBrowser) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
} catch (SWTError e) {
MessageBox messageBox = new MessageBox(shell, SWT.ICON_ERROR
| SWT.OK);
messageBox.setMessage("Browser cannot be initialized.");
messageBox.setText("Exit");
messageBox.open();
} catch (InterruptedException e) {
closeBrowser = true;
logger.info("Closing.");
} catch (Exception e) {
logger.error("Error while loading swt browser " + e);
} finally {
super.isOpen = false;
session.close();
}

in above code closeBrowser boolean is used to close the browser. i set it true from another thread.

I am not writing to anywhere in file system. All i am doing is calling above code in a separate thread in which i am calling browser.setUrl(...).I am showing the customer details from web server. URL is calling a jsp page.

if i open that page in IE 6.0 stand alone repeatedly then it has no problem. only when i call that page on swt repeatedly it starts asking me to open save or cancel the page.

It loads the jsp page first and then saves in temporary internet files and from there it asks me to open save and cancel option. I do understand why first time page loads in my swt browser perfectly and from second time it starts asking to save or open.

One more thing i want to add that above mentioned problem does not happen if i try to open google or yahoo websites. It happens when i try to open any intranet site like my URL or even tomcat's localhost:8080.

[Updated on: Fri, 26 March 2010 12:09]

Report message to a moderator

Re: SWT Browser problem [message #523463 is a reply to message #523383] Fri, 26 March 2010 09:40 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2151
Registered: July 2009
Senior Member
In your snippet the only invocations on Browser are setSize() and setUrl(),
so nothing strange there. Questions:

- Is it possible that the content being received from the server is somehow
different after accessing it the first time? Open/Save/Cancel is usually
shown when the browser doesn't know how to handle the incoming content's
mime type.
- Is there any way for someone on the outside to access the page that
demonstrates the problem happening?
- Does invoking refresh() instead of setUrl() after the initial navigation
make any difference?
- Can you try this from the main thread instead of from the background
thread (most of SWT is meant to be run on the main thread)?

Grant


"Manish Veerwal" <manish.veerwal@gmail.com> wrote in message
news:hohu7r$207$1@build.eclipse.org...
> My code for browser is as follows:
>
> Display display = new Display();
> Shell shell = new Shell(display, SWT.TITLE);
> try {
> InteractiveAlert interactiveAlert = (InteractiveAlert) session
> .load(InteractiveAlert.class, alertID);
> if (delay > 0) {
> logger.debug("Interactive SWT Thread sleeping for " + delay);
> Thread.sleep(delay);
> updateStatus();
> }
> super.isOpen = true;
> shell.setText(interactiveParameters.getFrameTitle());
>
> Browser browser = new Browser(shell, SWT.NONE);
> browser.addCloseWindowListener(new CloseWindowListener() {
>
> public void close(WindowEvent arg0) {
> closeBrowser = true;
> }
> });
>
> if (interactiveParameters.isFullScreenMode()) {
> Monitor monitor = shell.getMonitor();
> Rectangle bounds = monitor.getBounds();
> browser.setSize(bounds.width, bounds.height);
> } else {
> browser.setSize(interactiveParameters.getBrowser_width(),
> interactiveParameters.getBrowser_height());
> shell.setSize(interactiveParameters.getBrowser_width(),
> interactiveParameters.getBrowser_height());
> }
>
> String url = createURL(interactiveAlert);
> browser.setUrl(url);
>
> if (interactiveParameters.isBeepEnabled()) {
> // display.beep();
> System.out.print("\007");
> System.out.flush();
> }
> shell.open();
> shell.setFullScreen(interactiveParameters.isFullScreenMode() );
> shell.setMinimized(interactiveParameters.isMinimizedMode());
> shell.forceActive();
> shell.setActive();
> while (!shell.isDisposed() && !closeBrowser) {
> if (!display.readAndDispatch()) {
> display.sleep();
> }
> }
> display.dispose();
> } catch (SWTError e) {
> MessageBox messageBox = new MessageBox(shell, SWT.ICON_ERROR
> | SWT.OK);
> messageBox.setMessage("Browser cannot be initialized.");
> messageBox.setText("Exit");
> messageBox.open();
> } catch (InterruptedException e) {
> closeBrowser = true;
> logger.info("Closing.");
> } catch (Exception e) {
> logger.error("Error while loading swt browser " + e);
> } finally {
> super.isOpen = false;
> session.close();
> }
>
> in above code closeBrowser boolean is used to close the browser. i set it
true from another thread.
>
> I am not writing to anywhere in file system. All i am doing is calling
above code in a separate thread in which i am calling browser.setUrl(...).I
am showing the customer details from web server. URL is calling a jsp page.
>
> if i open that page in IE 6.0 stand alone repeatedly then it has no
problem. only when i call that page on swt repeatedly it starts asking me to
open save or cancel the page.
>
> It loads the jsp page first and then saves in temporary internet files and
from there it asks me to open save and cancel option. I do understand why
first time page loads in my swt browser perfectly and from second time it
starts asking to save or open.
>
>
Re: SWT Browser problem [message #523648 is a reply to message #523234] Sun, 28 March 2010 01:40 Go to previous messageGo to next message
Tom  is currently offline Tom Friend
Messages: 1
Registered: March 2010
Junior Member
于 2010-3-25 23:36, Grant Gayed 写道:
> I have not heard of this before. Are you able to provide some means of
> reproducing the problem (eg.- a snippet like
> http://www.eclipse.org/swt/faq.php#whatisasnippet , an example of an html
> file that makes it happen, etc.)? To confirm, you're writing the content to
> the file system and then Browser.setUrl(...) to it? You mention using
> another thread, is the content definitely completely written before you try
> to show it? Does navigating to this file repeatedly in stand-alone IE6 work
> better?
>
> Grant
>
>
> "Manish Veerwal"<manish.veerwal@gmail.com> wrote in message
> news:hodfpr$k9$1@build.eclipse.org...
>> Recently, I have been developing a application which opens a SWT browser
> to browse the customer details. My application takes input from the other
> application and opens swt browser as new thread.
>>
>> As SWT browser uses IE for html rendering. It works fine with IE 7.0 or
> greater but with IE 6.0 it has some problem.
>>
>> When i start my application, for first time swt browser works fine and
> shows the page for given URL but from second time it starts asking to open
> save or cancel the html page which IE has rendered. It saves the current URL
> in IE temp files and tries to open it from that location and asks if i want
> to open save or cancel. If i click open then it opens into IE browser not
> into SWT display. SWT display remains blank and i get my URL opened into IE
> which i do not want to happen.
>>
>> Please can someone tell me what is going wrong?
>>
>
>
maybe it needs to set your application as the default browser
Re: SWT Browser problem [message #524035 is a reply to message #523463] Tue, 30 March 2010 12:27 Go to previous messageGo to next message
Manish Veerwal is currently offline Manish VeerwalFriend
Messages: 5
Registered: March 2010
Junior Member
Content is always same. It is not changing everytime. I think you can reproduce the problem. It is not even about the page. Problem even happens with the simple html page without any content in it. one can create a simple html page like:
<html>
<body>
</body>
</html>

put into your tomcat server and try to access it from swt browser repeatedly. problem happens if IE 6.0 is installed on the machine.


Re: SWT Browser problem [message #524357 is a reply to message #524035] Wed, 31 March 2010 15:37 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2151
Registered: July 2009
Senior Member
I've tried this with tomcat and don't see the problem. My test snippet is
different from yours though (pasted below), since I don't have the other
classes you were using. Are you able to reduce your case to one that shows
the problem but does not use any classes outside of swt? Also, what is your
stand-alone IE's version string from Help->About Internet Explorer? I have
6.0.2800.1106.

public class Main {
static boolean closeBrowser;
public static void main(String[] args) {
final Display display = new Display();
Shell shell = new Shell(display, SWT.TITLE);
// try {
// InteractiveAlert interactiveAlert = (InteractiveAlert)
session.load(InteractiveAlert.class, alertID);
// if (delay > 0) {
// logger.debug("Interactive SWT Thread sleeping for " + delay);
// Thread.sleep(delay);
// updateStatus();
// }
// super.isOpen = true;
shell.setText(/*interactiveParameters.getFrameTitle()*/"Shell title");

final Browser browser = new Browser(shell, SWT.NONE);
// the following listener is not expected to ever be invoked
browser.addCloseWindowListener(new CloseWindowListener() {
public void close(WindowEvent arg0) {
closeBrowser = true;
}
});

// if (interactiveParameters.isFullScreenMode()) {
// Monitor monitor = shell.getMonitor();
// Rectangle bounds = monitor.getBounds();
// browser.setSize(bounds.width, bounds.height);
// } else {
// browser.setSize(interactiveParameters.getBrowser_width(),
// interactiveParameters.getBrowser_height());
// shell.setSize(interactiveParameters.getBrowser_width(),
// interactiveParameters.getBrowser_height());
shell.setSize(250,250);
browser.setSize(200,200);
// }

final String url = /*createURL(*/"http://localhost:8080/test.html"/*)*/;
browser.setUrl(url);

// if (interactiveParameters.isBeepEnabled()) {
// // display.beep();
// System.out.print("\007");
// System.out.flush();
// }
shell.open();
// shell.setFullScreen(interactiveParameters.isFullScreenMode() );
// shell.setMinimized(interactiveParameters.isMinimizedMode());
shell.forceActive();
shell.setActive();
Runnable runnable = new Runnable() {
public void run() {
if (browser.isDisposed()) return;
System.out.println("here");
browser.setUrl(url);
display.timerExec(999, this);
}
};
display.timerExec(999, runnable);
while (!shell.isDisposed() && !closeBrowser) {
if (!display.readAndDispatch()) display.sleep();
}
// }
display.dispose();
// } catch (SWTError e) {
// MessageBox messageBox = new MessageBox(shell, SWT.ICON_ERROR |
SWT.OK);
// messageBox.setMessage("Browser cannot be initialized.");
// messageBox.setText("Exit");
// messageBox.open();
// } catch (InterruptedException e) {
// closeBrowser = true;
// logger.info("Closing.");
// } catch (Exception e) {
// logger.error("Error while loading swt browser " + e);
// } finally {
// super.isOpen = false;
// session.close();
// }
}
}

Grant


"Manish Veerwal" <manish.veerwal@gmail.com> wrote in message
news:hosqo6$ham$1@build.eclipse.org...
> Content is always same. It is not changing everytime. I think you can
reproduce the problem. It is not even about the page. Problem even happens
with the simple html page without any content in it. one can create a simple
html page like:
> <html>
> <body>
> </body>
> </html>
>
> put into your tomcat server and try to access it from swt browser
repeatedly. problem happens if IE 6.0 is installed on the machine.
>
>
>
Re: SWT Browser problem [message #524472 is a reply to message #524357] Thu, 01 April 2010 06:24 Go to previous messageGo to next message
Manish Veerwal is currently offline Manish VeerwalFriend
Messages: 5
Registered: March 2010
Junior Member
ok...below is my code snippet which i am using to recreate the problem:

public class SWTBrowser extends Thread {
public static final boolean FULL_SCREEN = false;

private Browser browser = null;

private Display display = null;

private Shell shell = null;

private boolean close = false;

private boolean urlChange = false;

private String url = null;

public SWTBrowser() {

}

@Override
public void run() {
show();
}

public void show() {
display = new Display();
shell = new Shell(display, SWT.CLOSE);

RowLayout rowLayout = new RowLayout(SWT.VERTICAL);
rowLayout.justify = true;
rowLayout.fill = true;

shell.setLayout(rowLayout);
shell.setText("Browser Example");
try {
browser = new Browser(shell, SWT.MIN);
browser.addCloseWindowListener(new CloseWindowListener() {

public void close(WindowEvent event) {
close = true;
}
});
if (FULL_SCREEN) {
Monitor monitor = shell.getMonitor();
Rectangle bounds = monitor.getBounds();
browser.setSize(bounds.width, bounds.height);
} else {
browser.setBounds(shell.getClientArea());
}

display.beep();
shell.pack();
shell.open();
browser.setUrl("http://localhost:8080");
shell.setFullScreen(FULL_SCREEN);
shell.setMinimized(false);
while (!shell.isDisposed() && !close) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
browser.dispose();
display.dispose();
} catch (SWTError e) {
MessageBox messageBox = new MessageBox(shell, SWT.ICON_ERROR
| SWT.OK);
messageBox.setMessage("Browser cannot be initialized.");
messageBox.setText("Exit");
messageBox.open();
System.exit(-1);
}
}

public void setURL() {
urlChange = true;
url = "http://localhost:8080";
}

public void close() {
close = true;
}

/**
* @param args
*/
public static void main(String[] args) {
SWTBrowser swtBrowser = new SWTBrowser();
for (int i = 0; i < Integer.parseInt(args[0]); i++) {
swtBrowser = new SWTBrowser();
swtBrowser.start();
swtBrowser.setURL();
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
swtBrowser.close();
}
}
}


In above code, if you run it , it will open a swt browser and then it will be closed after 5 secs. pass the args more than 4. Now if you let it run without your interaction means let the swt browser close after 5 secs it will work fine. but try to close the swt browser by clicking close button then from next time when next browser will open it will ask for open save and cancel.

My IE version is 6.0.2900.2180.xpsp_sp2_gdr.091208-2028
Re: SWT Browser problem [message #525793 is a reply to message #524472] Wed, 07 April 2010 19:48 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2151
Registered: July 2009
Senior Member
Hi, sorry for the late follow-up,

I actually see a crash when using this approach (IE6 on Windows 2000), so
there's definitely a problem here. My suspicion is that it's the use of
background threads, which should not be needed for what's being done here,
especially given how asynchronous the Browser is. I've re-written the
snippet to use a single thread and it works for me (no crash and does not
ask to save the file). Does this work better for you? Are you able to
transfer an approach like this into your app?

public class Main {
static boolean close = false;
static Display display;
static Shell lastShell;
static String URL = "..."; // TODO set this
public static void main(String[] args) {
display = new Display();
int count = Integer.parseInt(args[0]);
for (int i = 0; i < count; i++) {
display.timerExec(5000 * i, new Runnable() {
public void run() {
doit();
}
});
}
display.timerExec(5000 * count, new Runnable() {
public void run() {
close = true;
}
});
while (!close) {
if (!display.readAndDispatch()) display.sleep();
}
display.dispose();
}
static void doit() {
if (lastShell != null) lastShell.dispose();
Shell shell = new Shell(display, SWT.CLOSE);
lastShell = shell;
RowLayout rowLayout = new RowLayout(SWT.VERTICAL);
rowLayout.justify = true;
rowLayout.fill = true;
shell.setLayout(rowLayout);
shell.setText("Browser Example");

Browser browser = new Browser(shell, SWT.NONE);
browser.addCloseWindowListener(new CloseWindowListener() {
public void close(WindowEvent event) {
close = true;
}
});
browser.setBounds(shell.getClientArea());
Button button = new Button(shell, SWT.PUSH);
button.setText("HI");
display.beep();
shell.pack();
shell.open();
browser.setUrl(URL);
shell.setMinimized(false);
}
}

Grant


"Manish Veerwal" <manish.veerwal@gmail.com> wrote in message
news:hp1e6u$rlp$1@build.eclipse.org...
> ok...below is my code snippet which i am using to recreate the problem:
>
> public class SWTBrowser extends Thread {
> public static final boolean FULL_SCREEN = false;
>
> private Browser browser = null;
>
> private Display display = null;
>
> private Shell shell = null;
>
> private boolean close = false;
>
> private boolean urlChange = false;
>
> private String url = null;
>
> public SWTBrowser() {
>
> }
>
> @Override
> public void run() {
> show();
> }
>
> public void show() {
> display = new Display();
> shell = new Shell(display, SWT.CLOSE);
>
> RowLayout rowLayout = new RowLayout(SWT.VERTICAL);
> rowLayout.justify = true;
> rowLayout.fill = true;
>
> shell.setLayout(rowLayout);
> shell.setText("Browser Example");
> try {
> browser = new Browser(shell, SWT.MIN);
> browser.addCloseWindowListener(new CloseWindowListener() {
>
> public void close(WindowEvent event) {
> close = true;
> }
> });
> if (FULL_SCREEN) {
> Monitor monitor = shell.getMonitor();
> Rectangle bounds = monitor.getBounds();
> browser.setSize(bounds.width, bounds.height);
> } else {
> browser.setBounds(shell.getClientArea());
> }
>
> display.beep();
> shell.pack();
> shell.open();
> browser.setUrl("http://localhost:8080");
> shell.setFullScreen(FULL_SCREEN);
> shell.setMinimized(false);
> while (!shell.isDisposed() && !close) {
> if (!display.readAndDispatch()) {
> display.sleep();
> }
> }
> browser.dispose();
> display.dispose();
> } catch (SWTError e) {
> MessageBox messageBox = new MessageBox(shell, SWT.ICON_ERROR
> | SWT.OK);
> messageBox.setMessage("Browser cannot be initialized.");
> messageBox.setText("Exit");
> messageBox.open();
> System.exit(-1);
> }
> }
>
> public void setURL() {
> urlChange = true;
> url = "http://localhost:8080";
> }
>
> public void close() {
> close = true;
> }
>
> /**
> * @param args
> */
> public static void main(String[] args) {
> SWTBrowser swtBrowser = new SWTBrowser();
> for (int i = 0; i < Integer.parseInt(args[0]); i++) {
> swtBrowser = new SWTBrowser();
> swtBrowser.start();
> swtBrowser.setURL();
> try {
> Thread.sleep(5000);
> } catch (InterruptedException e) {
> e.printStackTrace();
> }
> swtBrowser.close();
> }
> }
> }
>
>
> In above code, if you run it , it will open a swt browser and then it will
be closed after 5 secs. pass the args more than 4. Now if you let it run
without your interaction means let the swt browser close after 5 secs it
will work fine. but try to close the swt browser by clicking close button
then from next time when next browser will open it will ask for open save
and cancel.
>
> My IE version is 6.0.2900.2180.xpsp_sp2_gdr.091208-2028
Re: SWT Browser problem [message #526544 is a reply to message #525793] Mon, 12 April 2010 08:59 Go to previous message
Manish Veerwal is currently offline Manish VeerwalFriend
Messages: 5
Registered: March 2010
Junior Member
I am sorry for late reply. Thank you very much. It has solved my problem. It was really a background thread problem. i made few changes also. Instead of closing browser using close boolean, I am calling shell.dispose() in asyncExec method. Thats work perfect.

Thank you.
Previous Topic:FocusListeners, part 2
Next Topic:[Cocoa] RuntimeException in SWT listener hangs everything
Goto Forum:
  


Current Time: Sat Aug 24 07:31:21 GMT 2019

Powered by FUDForum. Page generated in 0.02661 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top