NPE at setMargin on AbstractOrderedLayout in Beta9

Since I made the update to Beta9 my Application wasn’t able to start up anymore because of Null Pointer Exceptions. The NPE get thrown when I want to use setMargin on an AbstractOrderedLayout. The following is an example from our code:

AbstractOrderedLayout abstractPlzLayout = (AbstractOrderedLayout) mainPanel.getContent();
		abstractPlzLayout.setMargin(false);

When I outcomment the second line everything works fine again. This is reproducable in every class where I use it.

The problem is not with setMargin() but that the Panel, UI and Window classes no longer have a default content - see
this announcement
.

Replace your code with something like

VerticalLayout mainLayout = new VerticalLayout(); // by default, margin is false
mainPanel.setContent(mainLayout);

Then add your components to mainLayout instead of mainPanel.

Thanks for the quick answer. I hanven’t realized that detail about the default content.