2013-04-08 31 views
0

我试图将应用程序从vaadin 6.8迁移到vaadin 7.由于Form类在vaadin 7中不推荐使用,我试图用FieldGroup构建我的窗体并将它们与FormLayout一起显示。建筑不是问题,但布局不能如此顺畅。现在我有两个问题。如何在vaadin 7中像vaadin 6中的Form一样布置FormLayout?

  1. 如何在窗体的整个宽度上显示窗体描述?我希望它的宽度完全相同,不要在第二列也不要宽。

  2. 如何添加按钮(确定并取消),使它们彼此相邻,而不仅仅在第二列?像旧的Form类中的页脚一样。

这是可能的FormLayout或我有使用另一个布局?

感谢
拉斐尔

回答

3

注:我从字面上才开始在上周调查V7,所以我的回应谨慎...

这两个问题从事实干FormLayout从不提供页眉和页脚--Form类没有提供。

我会建议创建您自己的具有标题布局,FormLayout和页脚布局例如Form的等价物。 (没试过使用,可能需要使用一个网格布局,而不是为VerticalLayout的mainLaout)

public class FormComponent extends CustomComponent { 
    private Layout mainLayout; 

    protected Layout header; 
    protected Layout central; 
    protected Layout footer; 

    public FormComponent() { 
    init(new HorizontalLayout(), new FormLayout(), new HorizontalLayout()); 
    } 

    protected void init(Layout header, Layout central, Layout footer) { 
    this.footer = footer; 
    this.header = header; 
    this.central = central; 

    mainLayout = new VerticalLayout(); 
    mainLayout.addComponent(header); 
    mainLayout.addComponent(central); 
    mainLayout.addComponent(footer); 

    setCompositionRoot(mainLayout); 
    setSizeUndefined(); 
    } 

    public Layout getHeader() { 
    return header; 
    } 

    public Layout getCentral() { 
    return central; 
    } 

    public Layout getFooter() { 
    return footer; 
    } 
} 
+0

谢谢。我已经这样教了一些东西,但希望有一个内置的解决方案。如果实际上没有任何东西,我会再等一等,并接受你的回答。 – raffael 2013-04-09 10:16:17

2
  1. 在Vaadin 7没有内置组件相当于Vaadin 6表单组件。所以你必须创建你自己的。
  2. 创建新的Horizo​​ntalLayout并添加您的确定和取消按钮。然后将该Horizo​​ntalLayout添加到FormLayout。