GridLayout removeComponent doesn't work

I have a View which extends GridLayout and has a 2x2 - Matrix.

Now I want to programmatically remove a component in one of the cells of the GridLayout with:

this.removeComponent( component );

But the component doesn’t get removed at least the browser view doesn’t get updated.

I also used:

this.removeComponent( col , row , component );

But the problem is still the same.

UPDATE: When I first do a component count :

int c = this.getComponentCount();

I get four.

After the removeComponent I get THREE - so it get’s removed but the browser doesn’t reflect this.

Any ideas what the problem could be?

Thanks in advance,


Hi Frank,

Could you post your source code?

I tried a simple example and it works fine:

    protected void init(VaadinRequest request) {

        final GridLayout layout = new GridLayout(3, 1);

        final Label labelA = new Label("A");
        final Label labelB = new Label("B");
        final Button button = new Button("Remove A", new ClickListener() {

            public void buttonClick(ClickEvent event) {

        layout.addComponents(button, labelA, labelB);


I guess the it has to do with the fact that I don’t use this Vaadin-Push-Framework.


and then use the @Push - Annotation on the UI.

I will post my source code later - right now I don’t have it here.

Do you use UI.access() when making changes from the background thread?


I do not make changes from another thread. I just call removeComponent on one of my views and the component I want to remove is in a GridLayout.

All I want to do is in my View which is part of the MainUI:

removeComponent( col , row );

I want to remove a view from a certain cell in a GridLayout and it doesn’t work.
I enabled push and I can see that the atmosphere framework is configured and it seems to work. But the component isn’t removed - actually it seems that it is removed on the server but the client is not updated.

Best Regards,


Ok, then I don’t see how push is related. Source code?

This is the source code of the view with the GridLayout:

[font=courier new]
@Theme(value = “mytheme”)
@Widgetset( value = “info.frankmarx.MyAppWidgetset” )
@SpringView( name = “” )
@Scope( value = “prototype” )
public class MainView extends VerticalLayout implements View , ViewInstanceAccessControl {

public final static String VIEW_NAME = "main";
protected final GridLayout layout = new GridLayout( 2 , 2 );

IOtherService otherService;

MainMenuView mainMenuView;

LogoView logoView;

MGView mgView;

ShopFloorView shopFloorView;

MachineListView machineListView;

protected void initView() {"| Entering initView().");
    layout.setWidth(100, Unit.PERCENTAGE);
    layout.setHeight(100, Unit.PERCENTAGE);



    layout.addComponent(logoView, 0, 0);
    layout.addComponent(mgView, 0, 1);
    layout.addComponent(mainMenuView, 1, 0);
    layout.addComponent(shopFloorView, 1, 1);

    layout.setColumnExpandRatio(1, 4.0f);
    //this.setRowExpandRatio( 0 , 1.0f );


    float er = layout.getColumnExpandRatio(1);
    layout.setColumnExpandRatio(0, 1.0f);
    layout.setColumnExpandRatio(1, 10);
    layout.setComponentAlignment(mainMenuView, Alignment.TOP_LEFT);
    layout.setRowExpandRatio(1, 0.5f);

    mainMenuView.setWidth(100, Unit.PERCENTAGE);
    this.addComponent( layout );"| Exiting initView().");

public void enter(ViewChangeListener.ViewChangeEvent viewChangeEvent) {"| Entering enter with event {}.", viewChangeEvent.toString());"| Exiting enter.");

public boolean isAccessGranted(UI ui, String s, View view) {"| isAccessGranted was called with {} , {}" , s , view.toString() );
    return true;

public boolean setComponentForGrid( int column, int row, String viewName ) {

    if( viewName.equalsIgnoreCase( MACHINE_LIST_VIEW )) {
        int c = this.getComponentCount();
        layout.removeComponent( 1 , 1 );
        int x  = 0;
    return true;


The method “setComponentForForGrid” is called from a Click-Handler and is supposed to remove a component from the GridLayout - but the client doesn’t get updated.

Best Regards,


Hmmm … somehow it seems to work now.

I have no idea what went wrong - let’s hope it stays this way.

Thank you!