我有我的使用TabLayoutPanel的GWT應用程序,當我在Chrome中加載它時,一切正常。但是當我第一次加載ie9時,我沒有看到整個頁面:第一個標籤上的幾個標籤和圖像沒有加載。但是當我創建第二個選項卡然後打開第一個選項卡時,一切都很好。我在這個網站上發現了一些關於這個問題的問題,代碼是正確的。該問題必須在第一次上傳CSS。我比較了鉻和IE(第一負載和創建在TabLayoutPanel第二個選項卡之後)的代碼和這裏的結果當在IE中第一次打開時,GWT代碼無法正確顯示
鉻
<head>
<link rel="stylesheet" href="http://127.0.0.1:8888/myproject/Upload.css">
<style>
#loader{position:fixed;......A LOT OF STYLES...
</style>
</head>
<body style="margin: 0px;">
IE(第一負載)
<head>
<link rel="stylesheet" href="http://127.0.0.1:8888/myproject/Upload.css">
<style></style>
<style></style>
</head>
<body style="margin: 0px;">
<iframe>
...
<div style="height: 0px;">
...
<div style="top: 0px; bottom: 0px;">
</iframe>
IE(在TabLayoutPanel中創建第二個標籤之後)
<head>
<link rel="stylesheet" href="http://127.0.0.1:8888/myproject/Upload.css">
<style></style>
<style></style>
</head>
<body style="margin: 0px;">
<iframe>
...
<div style="height: 68px;">
...
<div style="top: 68px; bottom: 221px;">
</iframe>
請幫助我。我該怎麼辦?我需要在第一次加載時正確加載頁面。
Java代碼的
public void onModuleLoad() {
startAuthApplication();
}
private void startAuthApplication() {
AppController appController = new AppController();
appController.go(RootLayoutPanel.get());
}
/********************************************************************/
public class AppController{
public void go(final HasWidgets container) {
SystemPresenter systemPresenter = new SystemPresenter(AppFactory.getSystemView());
systemPresenter.go(container);
}
}
/********************************************************************/
public class SystemPresenter{
private final SystemView systemView;
public SystemPresenter(SystemView systemView) {
this.systemView = systemView;
}
public void go(HasWidgets container) {
container.clear();
container.add(systemView.asWidget());
}
}
/********************************************************************/
public class AppFactory {
private static SystemView systemView;
private static TabPanelViewImpl tabPanelView;
public static SystemView getSystemView() {
if (systemView == null) {
systemView = new SystemViewImpl();
}
return systemView;
}
public static TabPanelViewImpl getTabPanelView() {
if (tabPanelView == null) {
tabPanelView = new TabPanelViewImpl();
}
return tabPanelView;
}
}
/********************************************************************/
public class SystemViewImpl extends Composite implements SystemView {
interface Binder extends UiBinder<DockLayoutPanel, SystemViewImpl> {
}
private static Binder binder = GWT.create(Binder.class);
@UiField(provided = true)
TabPanelViewImpl tabPanelView;
public SystemViewImpl() {
tabPanelView = AppFactory.getTabPanelView();
initWidget(binder.createAndBindUi(this));
}
}
/********************************************************************/
public class TabPanelViewImpl extends Composite implements TabPanelView,
DocListEditDraftEventHandlers {
interface TabPanelViewImplBinder extends
UiBinder<TabLayoutPanel, TabPanelViewImpl> {
}
private static TabPanelViewImplBinder binder = GWT
.create(TabPanelViewImplBinder.class);
private TabPanelPresenter presenter;
@UiField(provided = true)
TabLayoutPanel tabPanel;
private DocListTableView docListTableView;
public TabPanelViewImpl() {
super();
tabPanel = new TabLayoutPanel(30, Unit.PX);
docListTableView = AppFactory.getDocListTableView();
tabPanel.add(docListTableView, "List of Docs");
initWidget(binder.createAndBindUi(this));
}
/********************************************************************/
public class DocListTableView extends Composite {
interface DocListTableViewUiBinder extends
UiBinder<Widget, DocListTableView> {
}
private static DocListTableViewUiBinder uiBinder = GWT
.create(DocListTableViewUiBinder.class);
private final DocListTableConstants constants = GWT
.create(DocListTableConstants.class);
private final Resources resources = GWT.create(Resources.class);
private final DocListTableResources resource = GWT
.create(DocListTableResources.class);
@UiField(provided = true)
CellTable<DocList> cellTable;
@UiField
Label emptyLabel;
@UiField(provided = true)
Label userLabel;
public DocListTableView() {
userLabel = new Label("User: "
+ AppFactory.getUserInfo().getUserName());
initWidget(uiBinder.createAndBindUi(this));
}
/********************************************************************/
DocListTableView.ui.xml
<ui:with field="res"
type="com.myproject.client.resources.DocListTableConstants" />
<g:DockLayoutPanel unit='EM'>
<g:north size='5'>
<g:HTMLPanel addStyleNames="{docListStyle.center}">
<g:HorizontalPanel width="100%">
<g:cell horizontalAlignment="ALIGN_LEFT">
<g:Label addStyleNames="{docListStyle.label}" ui:field="userLabel" />
</g:cell>
</g:HorizontalPanel>
<g:HorizontalPanel width="100%">
<g:cell horizontalAlignment="ALIGN_CENTER">
<g:Label addStyleNames="{docListStyle.label} {docListStyle.centerLabel}"
text="{res.label}" />
</g:cell>
</g:HorizontalPanel>
</g:HTMLPanel>
</g:north>
<g:center>
<g:HTMLPanel addStyleNames="{docListStyle.center1}">
<g:HorizontalPanel width="100%">
<g:cell horizontalAlignment="ALIGN_CENTER">
<g:Label ui:field="emptyLabel" visible="false">Your document list is empty</g:Label>
</g:cell>
</g:HorizontalPanel>
<table cellspacing='0' cellpadding='0'>
<tr>
<td valign='top'>
<ct:CellTable addStyleNames='{docListStyle.panel1}'
ui:field='cellTable' />
</td>
</tr>
<tr>
<td align='center'>
<my:DocListSimplePager ui:field='pager'
visible="false" />
</td>
</tr>
</table>
</g:HTMLPanel>
</g:center>
<g:south size='10'>
<g:HTMLPanel addStyleNames="{docListStyle.center}">
<g:Label addStyleNames="{docListStyle.label} {docListStyle.centerLabel}"
text="{res.status}" />
<table>
<tr>
<td>
<g:Image url="images/status/draft.png"></g:Image>
</td>
<td>
<div class="{docListStyle.label}">
<ui:text from='{res.draft}' />
</div>
</td>
<td>
<g:Image url="images/status/accept.png"></g:Image>
</td>
<td>
<div class="{docListStyle.label}">
<ui:text from='{res.accept}' />
</div>
</td>
</tr>
<tr>
<td>
<g:Image url="images/status/send.png"></g:Image>
</td>
<td>
<div class="{docListStyle.label}">
<ui:text from='{res.send}' />
</div>
</td>
<td>
<g:Image url="images/status/get.png"></g:Image>
</td>
<td>
<div class="{docListStyle.label}">
<ui:text from='{res.get}' />
</div>
</td>
</tr>
</table>
</g:HTMLPanel>
</g:south>
</g:DockLayoutPanel>
我知道我張貼了大量的代碼,但我希望它相當瞭解。我在TabLayoutPanel
的第一個選項卡上添加DocListTableView
,並在第一次加載時在DocListTableView.ui.xml
文件中僅顯示celltable + pager顯示。其他Labels
和<table>
元素不顯示。
編輯 接口Resources
和DocListTableResources
我cellTable使用和他們進行正確的渲染。
import com.google.gwt.resources.client.ClientBundle;
import com.google.gwt.resources.client.ImageResource;
public interface Resources extends ClientBundle {
@Source("draft.png")
ImageResource draft();
@Source("edit.png")
ImageResource edit();
...
}
import com.google.gwt.user.cellview.client.CellTable;
public interface DocListTableResources extends CellTable.Resources {
public interface DocListTableStyle extends CellTable.Style {
};
@Override
@Source({ "DocListTableStyle.css" })
DocListTableStyle cellTableStyle();
}
EDIT2
import com.google.gwt.i18n.client.ConstantsWithLookup;
public interface DocListTableConstants extends ConstantsWithLookup {
public String label();
public String status();
public String draft();
...
請顯示您的java代碼。你如何將TabLayoutPanel添加到接口? –
很難判斷實際發生了什麼問題 - 在最初的添加過程中,「DocListTableView」沒有被添加嗎?還是隻有它的資源?你能說明你如何使用DocListTableView中的'resources'和'resource'字段嗎?如果沒有更多的信息,很難說 - 也許你只需要在樣式上調用'ensureInjected()'或者在'Scheduler.get()。scheduleDeferred()'中添加'DocListTableView'。 –
@Igor Klimer,我編輯了我的問題。你提出'ensureInjected()'或'Scheduler.get()。scheduleDeferred()'。你能幫助我使用它嗎? – olgacosta