3

I'm using a number of core-ajax-dart elements on a web page. The custom events firing seems to be broken. When using the declarative on-core-response="{{ajaxNewProjectResponse}}" the element seems to want to fire the custom event, but there's a smoke package in the way that gives:

Missing method "null" in competences-service. Code generation for the smoke package seems incomplete.

If I do it imperatively, through ajaxNewProject.onCoreResponse.listen(ajaxNewProjectResponse);, it does work as expected (the event fires and my event method is called).

This used to work. I suspect it may have broken when updating polymer or core_elements versions, or when I started using more and more core-ajax-dart elements.

What I understand from the smoke package is that it may be related to the polymer transformer. The error leads me to believe that some code was not properly generated, and so may point out a framework bug, not a bug in my code. I could find relatively little about this error message, only https://groups.google.com/a/dartlang.org/forum/#!topic/web/INNHAZhLy1A, but I am not hiding expressions in strings in code. Am I on the right track here?

Error:

Exception: Uncaught Error: Missing method "null" in competences-service. Code generation for the smoke package seems incomplete.
Stack Trace:
#0      GeneratedObjectAccessorService.invoke (package:smoke/static.dart:127:7)
#1      invoke (package:smoke/smoke.dart:43:41)
#2      HtmlElement&Polymer.dispatchMethod (package:polymer/src/instance.dart:1138:19)
#3      BindingDelegate&PolymerEventBindings.getEventHandler.<anonymous closure> (package:polymer/src/events.dart:82:32)
#4      _RootZone.runUnaryGuarded (dart:async/zone.dart:1089)
#5      _RootZone.bindUnaryCallback.<anonymous closure> (dart:async/zone.dart:1118)
#6      BindingDelegate&PolymerEventBindings.prepareEventBinding.<anonymous closure>.<anonymous closure> (package:polymer/src/events.dart:101:67)
#7      BlinkEventTarget.dispatchEvent_Callback_Event (dart:_blink:42)
#8      EventTarget.dispatchEvent (dart:html:13924)
#9      HtmlElement&Polymer.fire (package:polymer/src/instance.dart:1201:23)
#10     CoreAjax.processResponse (package:core_elements/core_ajax_dart.dart:208:14)
#11     receive (package:core_elements/core_ajax_dart.dart:190:27)
#12     CoreXhr._makeReadyStateHandler.<anonymous closure> (package:core_elements/core_xhr_dart.dart:107:39)

My code: The full code on https://github.com/pjjjv/Akepot/tree/0b093b2b9671f4ce0351750d9ce3609dfb4e82f5. The core-ajax-dart elements are in lib/competences_service.html and to show the bug I have left the one with id ajaxNewProject with the declarative event handler.

An excerpt: Html:

<core-ajax-dart id="ajaxNewProject"
      url="https://1-dot-akepot-competence-matrix.appspot.com/_ah/api/akepot/v1/project/"
       on-core-response="{{ajaxNewProjectResponse}}" on-core-error="{{ajaxError}}"
      handleAs="json" method="POST">
    </core-ajax-dart>

Dart:

  void newProject(Project project){
    if(!signedin){
      throw new Exception("Not signed in.");
    }
    ajaxNewProject.url = "https://1-dot-akepot-competence-matrix.appspot.com/_ah/api/akepot/v1/project/$hash";
    ajaxNewProject.body = JSON.encode(project.toJson());
    ajaxNewProject.go();
  }

  @reflectable
  void ajaxNewProjectResponse(CustomEvent event, Map detail, CoreAjax node) {
    ...
  }

If you run the app, sign in at the left top, click Create project and then click Create project again. Then check the console.

pjv
  • 10,658
  • 6
  • 43
  • 60
  • 1
    Can you please add more of your code and your pubspec.yaml? – Günter Zöchbauer Dec 16 '14 at 21:15
  • Did you ever resolve this? I am having the same issue out of the sudden – Timo D Jan 19 '15 at 17:49
  • I didn't resolve it yet, but I workarounded it by going the imperative way. I added more code for Günter. I had planned to try this again in a week or so. – pjv Jan 22 '15 at 19:02
  • Tried again. Yes, I still have the problem. In some other Polymer element I was able to get another core-ajax-dart to work again though. – pjv Jan 22 '15 at 21:35
  • It can be related to the "The used expressions must already be used somewhere so Smoke knows to generate code for them." from http://stackoverflow.com/questions/23083760/dart-dynamic-usage-of-polymer-ui-tabs-and-polymer-ui-pages-does-not-work thread. But i don;t know - how to make smoke "understand" and process such expressions. @GünterZöchbauer - can you please explain this moment in more details? – TSV Mar 25 '15 at 19:40
  • It doesn't explain why some declarative event handler code keeps working, does it? – pjv Mar 26 '15 at 22:06

1 Answers1

0

In my experience, that's due to having more than one <script/> tag in a <polymer-element/>. You do have two <script/> tags. Does moving the <script src="../../packages/browser/dart.js"></script> bit outside of the <polymer-element/> help?

geppy
  • 604
  • 8
  • 10