내 GWT App 및 초기화 중에 CellTree를 생성하려고합니다. Showcase [ie onModuleLoad] 다음 오류가 발생합니다. 내가하려는 것은 GWT Showcase 앱을 복제하고 처음부터 빌드하는 것입니다.GWT CellTree 생성 문제
17:47:04.519 [ERROR] [ChannelView] Failed to create an instance of
'com.app.capture.client.ClientFactory' via deferred binding
java.lang.IllegalStateException: TreeNode no longer exists.
at com.google.gwt.user.cellview.client.CellTreeNodeView$TreeNodeImpl.assertNotDestroyed(CellTreeNodeView.java:653)
at com.google.gwt.user.cellview.client.CellTreeNodeView$TreeNodeImpl.setChildOpen(CellTreeNodeView.java:642)
at com.google.gwt.user.cellview.client.CellTreeNodeView$TreeNodeImpl.setChildOpen(CellTreeNodeView.java:637)
at com.app.capture.client.ui.MainMenuViewImpl.<init>(MainMenuViewImpl.java:35)
at com.app.capture.client.ClientFactory.<clinit>(ClientFactory.java:13)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at com.google.gwt.dev.shell.ModuleSpace.loadClassFromSourceName(ModuleSpace.java:665)
at com.google.gwt.dev.shell.ModuleSpace.rebindAndCreate(ModuleSpace.java:468)
at com.google.gwt.dev.shell.GWTBridgeImpl.create(GWTBridgeImpl.java:49)
at com.google.gwt.core.shared.GWT.create(GWT.java:57)
at com.google.gwt.core.client.GWT.create(GWT.java:85)
at com.app.capture.client.ChannelViewEntryPoint.onModuleLoad(ChannelViewEntryPoint.java:59)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:406)
at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:200)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:526)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
at java.lang.Thread.run(Thread.java:722)
UI는 세로로 나란히 놓인 2 개의 패널로 구성됩니다. 왼쪽은 셀 트리를 추가하고 싶은 탐색 패널입니다.
celltree 뷰 모델 클래스
package com.app.capture.client.ui.model;
import java.util.ArrayList;
import java.util.List;
import com.google.gwt.cell.client.AbstractCell;
import com.google.gwt.cell.client.Cell;
import com.google.gwt.cell.client.TextCell;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.google.gwt.view.client.ListDataProvider;
import com.google.gwt.view.client.SingleSelectionModel;
import com.google.gwt.view.client.TreeViewModel;
public class MainMenuViewModel implements TreeViewModel {
private static class Category {
private final String name;
private final List<String> items = new ArrayList<String>();
public Category(final String name) {
this.name = name;
}
public List<String> getItems() {
return this.items;
}
public String getName() {
return this.name;
}
public void addCategoryItem(String item) {
items.add(item);
}
}
private final List<Category> categories;
private final SingleSelectionModel<String> selectionModel = new SingleSelectionModel<String>();
public MainMenuViewModel() {
categories = new ArrayList<Category>();
Category apg = new Category("A");
apg.addCategoryItem("11");
apg.addCategoryItem("22");
Category channel = new Category("B");
channel.addCategoryItem("33");
channel.addCategoryItem("44");
channel.addCategoryItem("55");
categories.add(apg);
categories.add(channel);
}
@Override
public <T> NodeInfo<?> getNodeInfo(T value) {
if (value == null) {
// Root Level
ListDataProvider<Category> dataProvider = new ListDataProvider<Category>(categories);
Cell<Category> cell = new AbstractCell<Category>() {
@Override
public void render(com.google.gwt.cell.client.Cell.Context context, Category value, SafeHtmlBuilder sb) {
if (value != null) {
sb.appendEscaped(value.getName());
}
}
};
return new DefaultNodeInfo<Category>(dataProvider, cell);
} else if (value instanceof Category) {
ListDataProvider<String> dataProvider = new ListDataProvider<String>(((Category) value).getItems());
return new DefaultNodeInfo<String>(dataProvider, new TextCell(), selectionModel, null);
}
return null;
}
@Override
public boolean isLeaf(Object value) {
if (value instanceof String) {
return true;
}
return false;
}
}가
가메인 메뉴 뷰 내 클래스 정의
public class MainMenuViewImpl extends Composite implements MainMenuView {
interface MainMenuViewImplUiBinder extends UiBinder<Widget, MainMenuViewImpl> {
}
private static MainMenuViewImplUiBinder uiBinder = GWT.create(MainMenuViewImplUiBinder.class);
private Presenter presenter;
@UiField(provided = true)
CellTree mainMenu;
private MainMenuViewModel mainMenuModel;
public MainMenuViewImpl() {
mainMenuModel = new MainMenuViewModel();
mainMenu = new CellTree(mainMenuModel, null);
mainMenu.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);
TreeNode treeNode = mainMenu.getRootTreeNode();
// This is where the exception is throw. If i remove the following line, no menu is displayed
treeNode.setChildOpen(0, true);
initWidget(uiBinder.createAndBindUi(this));
}
@Override
public void setPresenter(Presenter presenter) {
this.presenter = presenter;
}
}
가MAINMENU 대한 내 UI 바인더 정의 임
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui"
xmlns:c="urn:import:com.google.gwt.user.cellview.client">
<ui:style>
.mainMenu {
background-color: #d7dde8;
border: 1px solid #c3c3c3;
}
</ui:style>
<g:VerticalPanel styleName="{style.mainMenu}">
<c:CellTree ui:field="mainMenu" />
</g:VerticalPanel>
</ui:UiBinder>
GWT 2.5.0을 사용하고 있습니다.
이 문제를 디버그하는 데 도움이되는 내용이나 조언은 크게 감사하겠습니다.
이 라인을 이동할 수 "treeNode.setChildOpen (0, true)를;" 어떤 위치에 트리의 렌더링을 "게시"합니다. – SSR
@SSR. uibinder에 대해 initWidget() API 뒤에 api를 호출하는 것을 의미합니까? 트리는 = true를 제공하므로 부모에게 연결되지 않은 것으로 렌더링됩니다. –