Thursday, 15 July 2010

java - Why do my events get lost? / Strange JavaScript Exception -



java - Why do my events get lost? / Strange JavaScript Exception -

i trying send event kid presenter mother presenter. first thought events lost. surrounded fireevent phone call try/catch block , error:

(-:-) 2014-11-06 10:13:26,069 [error] exception caught: com.google.gwt.core.client.javascriptexception: (typeerror) __gwt$exception: : cannot read property 'b' of undefined @ unknown.f2b(mdm-0.js@180:2440) @ unknown.k2b(mdm-0.js@182:2442) @ unknown.t2b(mdm-0.js@51:2448)

my original question got way long , edits may have confused people. constructed totally stripped-down example, error still occurs. create easier track error downwards (i hoped on way solve myself, can't). included imports now, sure not miss detail. have mother presenter (which stripped down), not anything:

package testproject.client.application.policies; import testproject.client.application.applicationpresenter; import testproject.client.application.policies.test.testpolicypresenterwidget; import testproject.client.events.testpolicyevent; import testproject.client.events.testpolicyevent.testpolicyeventhandler; import testproject.client.place.nametokens; import com.allen_sauer.gwt.log.client.log; import com.google.gwt.event.dom.client.clickevent; import com.google.gwt.event.dom.client.clickhandler; import com.google.gwt.event.dom.client.hasclickhandlers; import com.google.inject.inject; import com.google.web.bindery.event.shared.eventbus; import com.gwtplatform.mvp.client.presenter; import com.gwtplatform.mvp.client.view; import com.gwtplatform.mvp.client.annotations.nametoken; import com.gwtplatform.mvp.client.annotations.proxyevent; import com.gwtplatform.mvp.client.annotations.proxystandard; import com.gwtplatform.mvp.client.proxy.proxyplace; public class policypresenter extends presenter<policypresenter.myview, policypresenter.myproxy> implements testpolicyeventhandler { private testpolicypresenterwidget testpolicydialog; @proxystandard @nametoken(nametokens.policiespage) public interface myproxy extends proxyplace<policypresenter> { } public interface myview extends view { hasclickhandlers gettestpolicybutton(); } @inject policypresenter(eventbus eventbus, myview view, myproxy proxy, testpolicypresenterwidget testpolicydialog) { super(eventbus, view, proxy, applicationpresenter.slot_setmaincontent); this.testpolicydialog = testpolicydialog; } @override protected void onbind() { super.onbind(); addregisteredhandler(testpolicyevent.type, this); // handler add together policy button getview().gettestpolicybutton().addclickhandler(new clickhandler() { public void onclick(clickevent event) { log.debug("test policy received click event"); addtopopupslot(testpolicydialog); } }); } @override protected void onreveal() { super.onreveal(); } @override protected void onreset() { super.onreset(); } @proxyevent @override public void ontestpolicyevent(testpolicyevent event) { log.debug("testpolicycreatedevent caught"); } }

i added @proxyevent notation mentioned in comments, create sure...

this view reduced:

package testproject.client.application.policies; import javax.inject.inject; import testproject.client.model.containerpolicy; import testproject.client.resources.mdmtcelltableresources; import com.google.gwt.core.client.gwt; import com.google.gwt.event.dom.client.hasclickhandlers; import com.google.gwt.uibinder.client.uibinder; import com.google.gwt.uibinder.client.uifield; import com.google.gwt.user.cellview.client.celltable; import com.google.gwt.user.cellview.client.celltable.resources; import com.google.gwt.user.client.ui.button; import com.google.gwt.user.client.ui.widget; import com.google.gwt.view.client.provideskey; import com.gwtplatform.mvp.client.viewimpl; public class policyview extends viewimpl implements policypresenter.myview { private static final int pagesize = 15; interface binder extends uibinder<widget, policyview> { } private static final provideskey<containerpolicy> key_provider = new provideskey<containerpolicy>() { @override public object getkey(containerpolicy item) { homecoming item.getid(); } }; @uifield button testpolicybutton; @uifield(provided=true) celltable<containerpolicy> celltable = new celltable<containerpolicy>(pagesize, (resources)gwt.create(mdmtcelltableresources.class), key_provider); public hasclickhandlers gettestpolicybutton() { homecoming testpolicybutton; } public celltable<containerpolicy> getcelltable() { homecoming celltable; } @inject policyview(binder uibinder) { initwidget(uibinder.createandbindui(this)); } }

so when click button, presenter shown, using addtopopupslot(testpolicydialog);.

my kid presenter (widget) totally stripped downwards now: presenter:

package testproject.client.application.policies.test; import testproject.client.events.testpolicyevent; import testproject.client.model.clientmodelprovider; import com.allen_sauer.gwt.log.client.log; import com.google.gwt.user.client.ui.checkbox; import com.google.gwt.user.client.ui.textbox; import com.google.inject.inject; import com.google.web.bindery.event.shared.eventbus; import com.gwtplatform.mvp.client.hasuihandlers; import com.gwtplatform.mvp.client.popupview; import com.gwtplatform.mvp.client.presenterwidget; import com.gwtplatform.mvp.client.annotations.proxyevent; public class testpolicypresenterwidget extends presenterwidget<testpolicypresenterwidget.myview> implements testpolicyuihandlers { private final eventbus eventbus; public interface myview extends popupview, hasuihandlers<testpolicyuihandlers> { checkbox getenabled(); checkbox getenforced(); textbox getpolicytype(); textbox getcontainergroup(); } @inject testpolicypresenterwidget(eventbus eventbus, myview view, clientmodelprovider clientmodelprovider) { super(eventbus, view); this.eventbus = eventbus; } protected void onbind() { super.onbind(); log.debug("eventbus in newpolicypresenter " + eventbus.tostring() + " hashcode " + eventbus.hashcode()); } @override protected void onreveal() { super.onreveal(); } @proxyevent @override public void createpolicy() { seek { log.debug("click event on ok button in add together policy dialog caught. "); log.debug("firing event"); eventbus.fireevent(new testpolicyevent()); log.debug("firing event, without stating eventbus:"); fireevent(new testpolicyevent()); } grab (exception e) { log.error("exception caught: ",e); } } }

view:

package testproject.client.application.policies.test; import testproject.client.model.containerpolicy; import com.google.gwt.editor.client.editor; import com.google.gwt.editor.client.simplebeaneditordriver; import com.google.gwt.event.dom.client.clickevent; import com.google.gwt.uibinder.client.uibinder; import com.google.gwt.uibinder.client.uifield; import com.google.gwt.uibinder.client.uihandler; import com.google.gwt.user.client.ui.button; import com.google.gwt.user.client.ui.checkbox; import com.google.gwt.user.client.ui.popuppanel; import com.google.gwt.user.client.ui.textbox; import com.google.inject.inject; import com.google.web.bindery.event.shared.eventbus; import com.gwtplatform.mvp.client.popupviewwithuihandlers; public class testpolicyview extends popupviewwithuihandlers<testpolicyuihandlers> implements testpolicypresenterwidget.myview, editor<containerpolicy> { interface binder extends uibinder<popuppanel, testpolicyview> { } public interface driver extends simplebeaneditordriver<containerpolicy, testpolicyview> { } @uifield checkbox enabled; @uifield checkbox enforced; @uifield textbox policytype; @uifield textbox containergroup; @uifield button okbutton; @uifield button cancelbutton; @inject testpolicyview(binder uibinder,eventbus eventbus) { super(eventbus); initwidget(uibinder.createandbindui(this)); } @uihandler("okbutton") void okbuttonclicked(clickevent event) { getuihandlers().createpolicy(); hide(); } @uihandler("cancelbutton") void cancelbuttonclicked(clickevent event) { hide(); } @override public checkbox getenabled() { homecoming enabled; } @override public checkbox getenforced() { homecoming enforced; } @override public textbox getpolicytype() { homecoming policytype; } @override public textbox getcontainergroup() { homecoming containergroup; } }

and, since somehow related js, ui.xml:

<!doctype ui:uibinder scheme "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:dialogbox modal="false"> <g:caption> <b>policy</b> </g:caption> <g:htmlpanel> <div class="locked"> <div class="lockedpanel float-wrapper container-edit"> <!-- device block --> <div class="panel panel-default"> <div class="panel-heading"> <h4 class="panel-title">policy</h4> </div> <div class="panel-body"> <form class="form-bordered"> <div class="form-group"> <label class="col-sm-4 control-label">enabled</label> <div class="col-sm-8"> <g:checkbox ui:field="enabled" stylename="form-control input-sm"/> </div> <label class="col-sm-4 control-label">enforced</label> <div class="col-sm-8"> <g:checkbox ui:field="enforced" stylename="form-control input-sm" /> </div> <label class="col-sm-4 control-label">policy type</label> <div class="col-sm-8"> <g:textbox ui:field="policytype" stylename="form-control input-sm"/> </div> <label class="col-sm-4 control-label">container group</label> <div class="col-sm-8"> <g:textbox ui:field="containergroup" stylename="form-control input-sm"/> </div> </div><!-- form-group --> </form> </div><!-- panel-body --> </div><!-- panel-default --> <div class="float-right"> <g:button ui:field="okbutton" stylename="btn btn-primary btn-bordered">ok</g:button> <g:button ui:field="cancelbutton" stylename="btn btn-primary btn-bordered">cancel</g:button> </div> </div><!-- lockedpanel --> </div> </g:htmlpanel> </g:dialogbox> </ui:uibinder>

i bind presenters in applicationmodule:

package testproject.client.application; ... public class applicationmodule extends abstractpresentermodule { @override protected void configure() { install(new uimodule()); // application presenters bindpresenter(applicationpresenter.class, applicationpresenter.myview.class, applicationview.class, applicationpresenter.myproxy.class); ... bindpresenter(policypresenter.class, policypresenter.myview.class, policyview.class, policypresenter.myproxy.class); bindsingletonpresenterwidget(testpolicypresenterwidget.class, testpolicypresenterwidget.myview.class, testpolicyview.class);} }

the error mentioned above happens when seek access object within createpolicy-method. e.g., when phone call this:

log.debug("click event on ok button in add together policy dialog caught. "); log.debug("firing event"); eventbus.fireevent(new testpolicyevent());

i error. not matter if utilize eventbus.fireevent or fireevent. happens when seek access other objects. guess problem not related event handling. cause this?

thanks help far , time reading this...

are sure exception beingness logged try/catch added? when utilize viewwithuihandlers, need set view's uihandlers manually. in testpolicypresenterwidget, need add together view.setuihandlers(this) in constructor, otherwise getuihandlers() homecoming null in view.

java gwt gwtp

No comments:

Post a Comment