Important Notice - Forums is archived

To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Product icon

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

ApplicationPortlet2 does Mantain Browser Scroll Position

Bruno Antunes
1 decade ago Apr 27, 2012 5:21pm

When dynamically adding new layout component to a Vaadin ApplicationPortlet2; this allways causes the browser to scroll to the top.

The same does not happen, when we execute the application outside of the portal or if we use the ApplicationPortlet (instead of ApplicationPortlet2)

To reproduce this we can use this simple code:

public class MyVaadinApplication extends Application {

    private Window window;

    public void init() {
	window = new Window("My Vaadin Application");

	Button button = new Button("Add button");
	button.addListener(new Button.ClickListener() {

	    public void buttonClick(ClickEvent event) {
		// The following code caused the browser to scroll up when using
		// ApplicationPortle2 on Liferay
		HorizontalLayout layout = new HorizontalLayout();
		Button msg = new Button("MyButton");
		Window main = event.getComponent().getApplication().getMainWindow();


When we click the "Add button", and having browsers scroll not set to top, it will scroll up
This does not happen if we use ApplicationPortlet, or run it outside of the portal (as a Vaadin Application)

Need some help to try to figure out this different behaviour

Attaching a vaadin application that can be used to reproduce this.

Versions Used
Vaadin Version: 6.6.8
Portlet Container: Liferay 6.0.6
Application Server: GlassFish 3.1.2

Bruno Antunes

Last updated on Apr, 27th 2012
Bruno Antunes
1 decade ago May 03, 2012 12:21pm