No announcement yet.
  • Filter
  • Time
Clear All
new posts

    Peculiar GWT, Maps and SmartGWT UI Issue

    Hi there! I have the most peculiar problem related to smartgwt, gwt and maps that i'm hoping someone can help out with.

    We use maps a lot in our app, utilizing the classic Branflake maps project for GWT bindings to the JS Maps api.

    In one place, we have a mapwidget with a TextBox used with Googles AutoComplete feature, which has worked fine. When user enters text, autocomplete will present some suggestions, and user can click on them. We can use that to move the map around.
    Click image for larger version

Name:	Screenshot 2018-11-22 at 21.59.19.png
Views:	69
Size:	370.1 KB
ID:	255932

    Now, i tried doing a little tweak today. Basically i wanted that if the user just presses enter, we'd click on the first row in the autocomplete results and use that. The only way to do that is by catching the press event and sending a "key down" event, since there is no API access to the data. (Tons of SO threads about this)
    However, i noticed, that when i press enter in the autocomplete box, the dropdown with suggestions disappear. This is strange, since it does not happen in the maps showcase.

    You can test the functionality as exptected in the Branflake showcase (, scroll down to the "autocomplete" widget and notice that when you have search results, you can press enter in the text box without the results disappearing.


    After several hours of experimenting, i have come to the following scenario:

    I have a small stand-alone, runnable test project that just adds a GWT TextBox and a mapwidget to the RootPanel, which works as expected.

    If i just use GWT components, i can press enter in the search box without the dropdown disappearing.
    If i then just change gwt.xml to include the "SmartGwtEENoScriptNoTheme", and the html to include the GWT modules, the behaviour of the GWT Textbox changes so that if i press enter, the autocomplete results are cleared...

    I am not super-great at GWT/SmartGWT interoperability, so it would be fantastic if someone could chip in with thoughts about what i can do, if anything.

    I am happy to share my entire project, but since i can't upload zip files, i uploaded the main Java entrypoint-class. Let me know if i can provide any more information.
    Attached Files

    First thing to do is try both possible variations of JS loading order: loading the SmartClient runtime last is usually better, as we are careful not to interfere, but if you are already doing that, you should try reversing the order.


      OK, so i tried changing the order in my HTML:

       <script> var isomorphicDir = "maptest/sc/"; </script> <script type="text/javascript" language="javascript" src="maptest/maptest.nocache.js"></script> <script src="maptest/sc/modules/ISC_Core.js"></script> <script src="maptest/sc/modules/ISC_Foundation.js"></script> <script src="maptest/sc/modules/ISC_Containers.js"></script> <script src="maptest/sc/modules/ISC_Grids.js"></script> <script src="maptest/sc/modules/ISC_Forms.js"></script> <script src="maptest/sc/modules/ISC_Calendar.js"></script> <script src="maptest/sc/modules/ISC_DataBinding.js"></script>
      I.e. putting the "maptest.nocache" before and after the ISC scripts. No difference.

      I also played around with the "inherits" in the GWT.xml, putting the "no theme" first and last:

       <inherits name=''/> <inherits name=""/> <inherits name=""/> <inherits name="com.smartgwtee.SmartGwtEENoScriptNoTheme"/>
      No difference there either.

      The only thing that makes a difference is if i move out all Smartgwt references in the java entrypoint class, and do not load the ISC javascripts. Then it works.

      Is this what you meant, or am i misunderstanding?


        Is the correct source for the included classes needed to run your repro code?


          It doesn't look like you've mentioned the version of SGWT that you're using. When you report a bug, you need to include which release you're using, preferably giving the exact dated version. See the FAQ.


            Right, sorry. I am currently using 6.0-p20171202. I bought 12 in May, but i haven't even had time to unzip it yet....

            As for branflake, yeah, i have a maven dependency there. Using 3.10.0-alpha-7, which is tle last release.
            Last edited by mathias; 30 Nov 2018, 02:55.


              We see that with the latest SGWT EE release and GWT 2.8.2, if return is hit the autocomplete list disappears, but if SGWT is not loaded into the project and the Framework JS isn't loaded, the list remains upon hitting return. So we believe we're reproducing what you've reported. (Nothing visible happens at all in the browser window upon hitting return without SGWT - is that what you expect?)

              Note however, we see that even in the working case, with no SGWT loaded, there is an exception thrown by the JS that is reported in the browser console. This is presumably a bug in the GWT APIs or the way you're using the APIs. It may be the slightly different error handling of SGWT interacting with this exception that causes the list to be dismissed.

              We're looking into it now. You may want to confirm that you also see this error.


                We see that if we add a try/catch handler around the code inside your method shown below (from your Java code sample), then the behavior without SmartGWT also becomes to dismiss the list - so the same as with SmartGWT:

                public void onEvent(PlaceChangeMapEvent event) {
                    PlaceResult result = autoComplete.getPlace();
                    PlaceGeometry geomtry = result.getGeometry();
                    LatLng center = geomtry.getLocation(); // this line throwing the exception
                    // mapWidget.setZoom(8);
                    GWT.log("place changed center=" + center);
                The exception reported by the try/catch is:
       (TypeError) : Cannot read property 'location' of undefined
                So it appears that SmartGWT is just providing some additional exception handling. The real problem is the GWT Maps API usage in your handler, or perhaps in GWT Maps itself. You should probably report this as a GWT Maps issue.


                  Hi, thanks for getting back to me.

                  Well, actually it's not a fault in GWT maps, it is in my code you could say.

                  Since i posted this, i went back and "cleaned up" my code, and then i also started getting it with or without SmartGWT. my new code:

                  autoComplete.addPlaceChangeHandler(event -> {
                      PlaceResult result = autoComplete.getPlace();
                      PlaceGeometry geo = result.getGeometry();
                      if(geo != null){
                          LatLng center = geo.getLocation();
                          if(center != null){
                              createOrMoveMarkerAndCenter(center, MapConstants.MAP_LOCATIONSELECT_ZOOM_LEVEL);
                  The thing is, depending on what has been returned by the autocomplete maps-calls to google, and what is in the search result when enter is pressed in the textbox, the "result" might or might not have a PlaceGeometry. If i do the checks in the code above, no exceptions are ever thrown, and the dropdown always disappears.
                  I didn't think to do console debugging of the branflake showcase, so thanks for that! You guys are smart :)

                  Still no closer to a solution as to how i prevent the dropdown from disappearing. Tried adding a keydownhandler to the textbox and just cancelling all enter keyevents, does nothing, and in the "placechangehandler" method above, i think that the dropdown has already been closed.

                  The larger problem, is that the Branflake library hasn't been updated in 5 years and the author now works at Sencha, so it is unlikely to receive more updates (He's the one behind the maps stuff that Sencha has).
                  What i probably would need to do, is to fork the branflake stuff and try to update the bindings somehow.

                  I think i asked this somewhere else, but you're not by any chance working on some Google-maps-widget for smartGWT? Great competetive advantage, you know! :)

                  Anyway, thanks for looking into it.