GWT Stacklayout面板不显示除标题之外的子窗口小部件

时间:2015-05-20 18:01:24

标签: uibinder

我第一次使用stacklayout面板。 我阅读了gwt文档,发现父母应该是一种布局。

下面是我的父窗口小部件代码(" EncounterViewImpl"),它创建了一个TabLayout面板和我的小部件" StudyViewImpl"位于此tablayout的其中一个标签上。

EncounterViewImpl.ui.xml(父)

  <!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder
   xmlns:ui="urn:ui:com.google.gwt.uibinder"
   xmlns:g="urn:import:com.google.gwt.user.client.ui"
   xmlns:hpi="urn:import:com.zoomcare.emrgwt.client.ui.encounter.hpi"
   xmlns:history="urn:import:com.zoomcare.emrgwt.client.ui.encounter.history"
   xmlns:medication="urn:import:com.zoomcare.emrgwt.client.ui.encounter.medication"
   xmlns:physical="urn:import:com.zoomcare.emrgwt.client.ui.encounter.physical"
   xmlns:diagnosis="urn:import:com.zoomcare.emrgwt.client.ui.encounter.diagnosis"
   xmlns:wellness="urn:import:com.zoomcare.emrgwt.client.ui.encounter.wellness"
   xmlns:study="urn:import:com.zoomcare.emrgwt.client.ui.encounter.study"
  xmlns:dental="urn:import:com.zoomcare.emrgwt.client.ui.encounter.dental">
<g:TabLayoutPanel barUnit="PX" barHeight="30" width="100%" height="100%">
    <g:tab visible="false">
        <g:header>
            Dental
        </g:header>
        <g:ScrollPanel width="98%" height="100%">
            <dental:EncounterDentalViewImpl ui:field="encounterDentalView"/>
        </g:ScrollPanel>
    </g:tab>
    <g:tab visible="false">
        <g:header>
            Study
        </g:header>
        <g:ScrollPanel width="98%" height="100%">
            <study:StudyViewImpl ui:field="studyView"/>
        </g:ScrollPanel>
    </g:tab>
   </g:TabLayoutPanel>

StudyViewImpl.ui.xml(儿童)

  <!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
 <ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
         xmlns:g='urn:import:com.google.gwt.user.client.ui'>
            <g:StackLayoutPanel height="100%" width="98%" ui:field="stackPanel" >

            </g:StackLayoutPanel>

我想通过相应的Activity类动态地将小部件添加到堆栈面板.StudyActivity在获得服务响应后调用setStudies(List list)

以下是代码.. StudyViewImpl.java

public class StudyViewImpl extends Composite implements StudyView {

private static LocalUiBinder uiBinder = GWT.create(LocalUiBinder.class);
interface LocalUiBinder extends UiBinder<StackLayoutPanel, StudyViewImpl> {
}

private StudyInfoActivityPiece presenter;

@UiField
StackLayoutPanel stackPanel ;


public StudyViewImpl() {
    initWidget(uiBinder.createAndBindUi(this));
    //stackPanel.setWidth("800");
}

  public void setStudies(List<ScheduledStudyGWT> studies){
    for(ScheduledStudyGWT study : studies) {
        VerticalPanel vPanel = new VerticalPanel();
        vPanel.setWidth("100%");
        vPanel.setHeight("100%");
        StudyInfoWidget infoWidget =  new StudyInfoWidget();
        infoWidget.setWidth("100%");
        infoWidget.setHeight("100%");
        infoWidget.populate(study);
        infoWidget.setReadOnly(false);
        ExamNoteWidget examNoteWidget =  new ExamNoteWidget();
        examNoteWidget.setWidth("100%");
        examNoteWidget.setHeight("100%");
        examNoteWidget.setExamNote(study.getExamNote());
        examNoteWidget.setReadOnly(false);
        InstructionsWidget instructionsWidget =  new InstructionsWidget();
        instructionsWidget.setInstructions(study.getInstructions());
        instructionsWidget.setWidth("100%");
        instructionsWidget.setHeight("100%");
        instructionsWidget.setReadOnly(false);
        vPanel.setVisible(true);
        vPanel.add(infoWidget);
        vPanel.add(examNoteWidget);
        vPanel.add(instructionsWidget);
        stackPanel.add(vPanel,createHeaderWidget(study.getOrderedLab().getLab().getName()),30);
    }
}

private Widget createHeaderWidget(String text) {
    HorizontalPanel hPanel = new HorizontalPanel();
    hPanel.setHeight("100%");
    hPanel.setSpacing(0);
    hPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    HTML headerText = new HTML(text);
    hPanel.add(headerText);
    return new SimplePanel(hPanel);
}

}

当我运行上面的代码时,我看到通过传递正确的对象列表来调用setStudies方法,但是在浏览器上我只看到了标题。

请帮我弄清楚问题。

1 个答案:

答案 0 :(得分:0)

我使用StackPanel修复了问题。我在quirk模式下运行,因此转移到StackPanel而不是StackLayoutPanel,仅在标准模式下支持。