I noticed that if an html link of a CustomLayout (haven’t tried the vaadin link) is clicked, then IE 7 sends “close” to server, hence the windowClose() is fired. This does not happen on any other non - Microsoft browsers (i.e. FF, Chrome).
i.e.
when clicking the following link on a custom layout on IE 7 , windowClose() is fired on the Window server component.
<a href="#test" class="myclass">test link</a>
Can someone please tell why this is happening and whether it could be avoided??
I tried the same example with a vaadin link and i get the same behavior. No close events are sent by non-IE browsers, which is the normal behavior. However IE sends a close event.
The code to test this is the following,
public class Main extends Application {
@Override
public void init() {
TestLinks testLinks = new TestLinks();
setMainWindow(testLinks );
}
}
public class TestLinks extends Window {
public TestLinks() {
super("test links");
init();
}
private void init() {
try {
String htmlCode = "<div><p>LINK 1</p><div location=\"use_case_description\"></div><p>LINK 2</p><a href=\"#test\" class=\"myclass\">html link</a></div>";
CustomLayout customLayout = new CustomLayout(new ByteArrayInputStream(htmlCode.getBytes()));
setContent(customLayout);
addListener(new CloseListener() {
public void windowClose(CloseEvent e) {
System.out.println("CLOSE WINDOW : " + getName());
}
});
Link vTestLink = new Link("vaadin link", new ExternalResource("#test2"));
customLayout.addComponent(vTestLink, "use_case_description");
} catch (Exception e) {
}
}
}
Can please someone explain the reason that only IE sends a close event? This causes some trouble, it would be very helpful if we could avoid this close event somehow.
I would be very gratful for any help. Thank you guys.
Do you have URIFragmentUtility on your page? It’s IE implementation may need to refresh the whole page when fragment changes. This might cause onclose event. Instead of using links it would better be using buttons for navigation (with “link” style if visuals matters) and just update the fragment from the clicklistener.
Yes I use URIFragmentUtility and indeed it is possible to avoid this by using buttons.
However I need to use common links in order to be able to open the application in new tab and new window, via right-click etc…
I noticed that this event is sent before even processing the fragment.
Unfortunately it seems that IE causes this event because of its javascript (gwt/client-vaadin) interpretation. It actually sends via UIDL the “close” variable when the url changes. But I haven’t figured out the reason
The same behavior can also be observed on http://demo.vaadin.com/sampler. The first time when visiting the sampler from IE, if one clicks a link (not from the tree) it issues a close event and the initial page is shown before navigating to the link destination. On other browsers when clicking a link the sampler navigates directly to the link destination without showing the initial page.
It seems when IE 7 is interpreting the vaading-client code it sends a “close” variable, which leads to a close event. Can someone please shed some light on this? should this be reported as an issue ?