2013-04-08 30 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。