0

I'm looking for a way to create a footer in my VerticalLayout. There are some way to create footer with VerticalLayout ?

Any idea ?

FernandoPaiva
  • 4,410
  • 13
  • 59
  • 118

3 Answers3

1

A simple solution. André Schild has already given a valuable input.

VerticalLayout vlMain = new VerticalLayout();
vlMain.setSizeFull();

HorizontalLayout hlFooter = new HorizontalLayout();
hlFooter.setHeight("50px"); // if you want you can define a height.
hlFooter.addComponent(new Label("Test1")); // adding a simple component. You might want to set alignment for that component

vlMain.addComponent(mainComponent);
vlMain.setExpandRatio(mainComponent, 1.0f); // "give" the main component the maximum available space
vlMain.addComponent(hlFooter);
nexus
  • 2,937
  • 3
  • 17
  • 22
0

It depends what you mean by footer, but the simplest way would be to add a HorizontalLayout as the last element in the VerticalLayout.

Just make sure the other components inside the VerticalLayout are set to expand by the container. (Look for setExpandRatio(...) in the VerticalLayout component.

André Schild
  • 4,592
  • 5
  • 28
  • 42
  • I'm trying use setExpandRatio(footer, 1.0f) but doesn't work. I'm trying this. ` public class PrincipalLayout extends VerticalLayout{ private HorizontalLayout footer; public PrincipalLayout(){ footer = new HorizontalLayout(); this.addComponent(footer); this.setExpandRatio(footer, 1.0f); } } ` – FernandoPaiva Jan 23 '14 at 19:38
  • You must not set the expandratio of the footer, but of the other components. When a component has NOT set a ExpandRatio, then it will not expand/shrink. Lookl here https://vaadin.com/de/book/-/page/layout.orderedlayout.html for a example. – André Schild Jan 24 '14 at 07:10
0

Now I solved my problem, I did this and works.

public class PrincipalLayout extends VerticalLayout{
private HorizontalLayout header, center, footer;

public PrincipalLayout(){       
    setSizeFull();      
    initComponents();
    defineLayout();
}

private void initComponents(){
    header = new HorizontalLayout();        
    center = new HorizontalLayout();        
    footer = new HorizontalLayout();        

    header.addComponent(new Label("HEADER"));
    center.addComponent(new Label("CENTER"));
    footer.addComponent(new Label("FOOTER"));
}

private void defineLayout(){
    addComponent(header);
    addComponent(center);
    addComponent(footer);

    setExpandRatio(center, 1.0f);
}

}

FernandoPaiva
  • 4,410
  • 13
  • 59
  • 118