2013-03-12 3 views
2

GWT의 lazypanel 유틸리티를 배우고 싶습니다. 나는 Uibinder를 사용하여 그것을 사용하고 싶다. 아래 코드를 작성했습니다. tablayoutpanel에 게으른 패널을 사용하고 싶습니다.LazyPanel in GWT (Uibinder)

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:d="urn:import:com.google.gwt.dom.client" 
    xmlns:lazy="urn:import:abc.client"> 

<g:HTMLPanel> 
    <lazy:Lazy1></lazy:Lazy1> 
</g:HTMLPanel> 



</ui:UiBinder> 

이 관련된 자바 파일입니다. Lazy1.java

package abc.client; 

import com.google.gwt.user.client.ui.Label; 
import com.google.gwt.user.client.ui.LazyPanel; 
import com.google.gwt.user.client.ui.Widget; 

public class Lazy1 extends LazyPanel{ 

    Label label = new Label("Mani"); 

    @Override 
    protected Widget createWidget() { 
     return label; 
    } 
} 

나는 아래와 같은 예외 사항, 오류를 얻고있다 : -

13:00:08.222 [ERROR] [abc] Generator 'com.google.gwt.uibinder.rebind.UiBinderGenerator' threw an exception while rebinding 'abc.client.AbcUI.abcUIUiBinder' 

java.lang.NullPointerException: null 
    at com.google.gwt.uibinder.elementparsers.LazyPanelParser.parse(LazyPanelParser.java:40) 
    at com.google.gwt.uibinder.rebind.UiBinderWriter.parseElementToField(UiBinderWriter.java:934) 
    at com.google.gwt.uibinder.elementparsers.WidgetInterpreter.interpretElement(WidgetInterpreter.java:88) 
    at com.google.gwt.uibinder.elementparsers.WidgetInterpreter.interpretElement(WidgetInterpreter.java:34) 
    at com.google.gwt.uibinder.elementparsers.InterpreterPipe.interpretElement(InterpreterPipe.java:58) 
    at com.google.gwt.uibinder.rebind.GetInnerHtmlVisitor.visitElement(GetInnerHtmlVisitor.java:45) 
    at com.google.gwt.uibinder.rebind.ChildWalker.accept(ChildWalker.java:48) 
    at com.google.gwt.uibinder.rebind.GetInnerHtmlVisitor.getEscapedInnerHtml(GetInnerHtmlVisitor.java:33) 
    at com.google.gwt.uibinder.rebind.XMLElement.consumeInnerHtml(XMLElement.java:391) 
    at com.google.gwt.uibinder.rebind.XMLElement.consumeInnerHtml(XMLElement.java:403) 
    at com.google.gwt.uibinder.elementparsers.HTMLPanelParser.parse(HTMLPanelParser.java:57) 
    at com.google.gwt.uibinder.rebind.UiBinderWriter.parseElementToField(UiBinderWriter.java:934) 
    at com.google.gwt.uibinder.rebind.UiBinderParser.parse(UiBinderParser.java:146) 
    at com.google.gwt.uibinder.rebind.UiBinderWriter.parseDocumentElement(UiBinderWriter.java:1368) 
    at com.google.gwt.uibinder.rebind.UiBinderWriter.parseDocument(UiBinderWriter.java:1073) 
    at com.google.gwt.uibinder.rebind.UiBinderGenerator.generateOnce(UiBinderGenerator.java:177) 
    at com.google.gwt.uibinder.rebind.UiBinderGenerator.generate(UiBinderGenerator.java:129) 
    at com.google.gwt.core.ext.IncrementalGenerator.generateNonIncrementally(IncrementalGenerator.java:40) 
    at com.google.gwt.dev.javac.StandardGeneratorContext.runGeneratorIncrementally(StandardGeneratorContext.java:657) 
    at com.google.gwt.dev.cfg.RuleGenerateWith.realize(RuleGenerateWith.java:41) 
    at com.google.gwt.dev.shell.StandardRebindOracle$Rebinder.rebind(StandardRebindOracle.java:79) 
    at com.google.gwt.dev.shell.StandardRebindOracle.rebind(StandardRebindOracle.java:276) 
    at com.google.gwt.dev.shell.ShellModuleSpaceHost.rebind(ShellModuleSpaceHost.java:141) 
    at com.google.gwt.dev.shell.ModuleSpace.rebind(ModuleSpace.java:595) 
    at com.google.gwt.dev.shell.ModuleSpace.rebindAndCreate(ModuleSpace.java:465) 
    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 abc.client.AbcUI.&lt;clinit&gt;(AbcUI.java:12) 
    at abc.client.ABC.onModuleLoad(ABC.java:10) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
    at java.lang.reflect.Method.invoke(Method.java:597) 
    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:662) 

ABC.java

package abc.client; 

import com.google.gwt.core.client.EntryPoint; 
import com.google.gwt.user.client.ui.RootPanel; 


public class ABC implements EntryPoint { 

    public void onModuleLoad() { 
     RootPanel.get().add(new AbcUI()); 
    } 
} 

AbcUi.java

package abc.client; 

import com.google.gwt.core.client.GWT; 
import com.google.gwt.uibinder.client.UiBinder; 
import com.google.gwt.user.client.ui.Composite; 
import com.google.gwt.user.client.ui.HTMLPanel; 
import com.google.gwt.user.client.ui.LazyPanel; 

public class AbcUI extends Composite { 

    interface abcUIUiBinder extends UiBinder<HTMLPanel, AbcUI> {} 
    private static abcUIUiBinder uiBinder = GWT.create(abcUIUiBinder.class); 


    public AbcUI() { 
     initWidget(uiBinder.createAndBindUi(this)); 
    } 
} 
+0

당신이 ABC.java''게시 할 수 및 그래서 나는 다음을 시도 것 아마도'AbcUi.java'? – enrybo

+0

@enrybo 두 파일을 모두 게시했습니다. – Mani

답변

2

에 따르면 ~ this LazyPanel에 @UiField 주석이 없으면이 오류가 발생합니다. 당신의 AbcUi.java 파일의 경우

<!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:d="urn:import:com.google.gwt.dom.client" 
    xmlns:lazy="urn:import:abc.client"> 

    <g:HTMLPanel> 
     <lazy:Lazy1 ui:field="myLazy1"/> 
    </g:HTMLPanel> 

</ui:UiBinder> 

:

UiBinder XML 파일에 대한 :

package abc.client; 

import com.google.gwt.core.client.GWT; 
import com.google.gwt.uibinder.client.UiBinder; 
import com.google.gwt.user.client.ui.Composite; 
import com.google.gwt.user.client.ui.HTMLPanel; 
import com.google.gwt.user.client.ui.LazyPanel; 

public class AbcUI extends Composite { 

    interface abcUIUiBinder extends UiBinder<HTMLPanel, AbcUI> {} 
    private static abcUIUiBinder uiBinder = GWT.create(abcUIUiBinder.class); 

    @UiField 
    Lazy1 myLazy1; 

    public AbcUI() { 
     initWidget(uiBinder.createAndBindUi(this)); 
    } 
} 
+0

LazyPanel이 작동하도록 uifield 주석을 선언해야하는 이유는 무엇입니까? 나는 가로 패널, 세로 패널 등과 같은 다른 패널을 사용할 때 필요하지 않습니다. – Mani

+0

정말 잘 모르겠습니다. 어쩌면 버그 일 수 있습니다. 내 고침이 효과가 있었나요? – enrybo

+0

예, 작동했습니다. – Mani