无法添加两个字幕面板

时间:2013-08-22 09:30:52

标签: java xml gwt

我正在写GWT客户端。 这是我的代码:

<g:center type="g:SingleChildWidgetType">
        <g:CaptionPanel captionText="Foreign Data" ui:field="cpForeignData">
            <g:ResizeLayoutPanel width="100%" height="100%">
                <p2:DataGrid ui:field="dataForeign" width="100%" height="100%" />
            </g:ResizeLayoutPanel>
        </g:CaptionPanel>
        <g:CaptionPanel captionText="Merged Data" ui:field="cpMergedData">
            <g:ResizeLayoutPanel width="100%" height="100%">
                <p2:DataGrid width="100%" height="100%" ui:field="dataMerged" />
            </g:ResizeLayoutPanel>
        </g:CaptionPanel>
    </g:center>

我在第二个字幕面板开始时出错:

cvc-complex-type.2.4.d: Invalid content was found starting with element 'g:CaptionPanel'. No child element is expected at this point.

有人知道这个问题的解决方案吗?

1 个答案:

答案 0 :(得分:4)

g:center 只接受一个子元素。尝试将CaptionPanel包装在一个符合您需求的容器中,例如VerticalPanel:

<g:center type="g:SingleChildWidgetType">
    <g:VerticalPanel>
        <g:CaptionPanel captionText="Foreign Data" ui:field="cpForeignData">
            <g:ResizeLayoutPanel width="100%" height="100%">
                <p2:DataGrid ui:field="dataForeign" width="100%" height="100%" />
            </g:ResizeLayoutPanel>
        </g:CaptionPanel>
        <g:CaptionPanel captionText="Merged Data" ui:field="cpMergedData">
            <g:ResizeLayoutPanel width="100%" height="100%">
                <p2:DataGrid width="100%" height="100%" ui:field="dataMerged" />
            </g:ResizeLayoutPanel>
        </g:CaptionPanel>
    </g:VerticalPanel>
</g:center>