Issue with DWR 3.0 Release and Google Maps API

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Issue with DWR 3.0 Release and Google Maps API

Dmitry Gorodnitsky
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Issue with DWR 3.0 Release and Google Maps API

david@butterdev.com
Thanks Dmitry.  Do you have this example deployed anywhere publicly so
we can take a look?

On 2015-09-30 22:04, Dmitry Gorodnitsky wrote:

> Hello, 
>
> We were successfully using combination DWR-3.0 Beta2 with Spring 4.1
> application. One of the screens was using Google Map.
> After upgrading to DWR-3.0 Release we found that the screen with
> Google Map functionality is not working any more. The tiles are loaded
> extremely slow and the page became unusable. 
> I unsuccessfully tried many options with DWR controller, such as 
>
>     <dwr:config-param name="allowScriptTagRemoting" value="false" />
>     <dwr:config-param name="crossDomainSessionSecurity"
> value="false" />
>
> I've created a sample page that shows the issue. If SessionService
> line is commented out the page is working without a problem. Just
> including any DWR service simply breaks functionality. 
>
> Any help would be greatly appreciated.
>
> Thanks,
>
> Dmitry Gorodnitsky
>
> DWR Spring Configuration
>
> <?xml version="1.0" encoding="UTF-8"?>
>  
> <beans xmlns="http://www.springframework.org/schema/beans [1]"
>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance [2]" 
>   xmlns:p="http://www.springframework.org/schema/p [3]"
>   xmlns:context="http://www.springframework.org/schema/context [4]"
>   xmlns:util="http://www.springframework.org/schema/util [5]"
>   xmlns:websocket="http://www.springframework.org/schema/websocket
> [6]"
>   xmlns:dwr="http://www.directwebremoting.org/schema/spring-dwr [7]"
>   xsi:schemaLocation="
>        http://www.springframework.org/schema/beans [1]
>      
>  http://www.springframework.org/schema/beans/spring-beans-4.0.xsd [8]
>        http://www.springframework.org/schema/context [4]
>      
>  http://www.springframework.org/schema/context/spring-context-4.0.xsd
> [9]
>        http://www.springframework.org/schema/util [5] 
>      
>  http://www.springframework.org/schema/util/spring-util-4.0.xsd [10]
>        http://www.springframework.org/schema/websocket [6]
>      
>  http://www.springframework.org/schema/websocket/spring-websocket-4.0.xsd
> [11]
>        http://www.directwebremoting.org/schema/spring-dwr [7]
>        http://www.directwebremoting.org/schema/spring-dwr-3.0.xsd
> [12]">
>        
>   <!--
> ###################################################################
> -->
>   <!-- #                        WEB SOCKET CONFIGURATION
>                 # -->
>   <!--
> ###################################################################
> -->
>   <!-- 
>   <websocket:handlers>
>     <websocket:mapping path="/websocket"
> handler="webSocketHandler"/>
>   </websocket:handlers>
>   <bean id="webSocketHandler"
> class="org.springframework.samples.MyHandler"/>
>    -->
>   
>   <!--
> ###################################################################
> -->
>   <!-- #                    DIRECT WEB REMOTING
> CONFIGURATION            # -->
>   <!--
> ###################################################################
> -->
>   <dwr:configuration>
>     <dwr:init></dwr:init>
>     <dwr:convert type="bean" class="java.lang.StackTraceElement" />
>     <dwr:convert type="bean" class="java.lang.Throwable" />
>     <dwr:signatures>
>       <![CDATA[
>         import java.util.Map; 
>         import java.util.List; 
>         import java.util.Collection; 
>       ]]>  
>     </dwr:signatures>
>   </dwr:configuration>
>   <dwr:annotation-config id="dwrAnnotationConfig"/>
>   <dwr:annotation-scan base-package="com.test"/>
>   <dwr:url-mapping />
>   
>   <dwr:controller id="dwrController" debug="true" />
> </beans>
>
> <!DOCTYPE html>
> <html>
>
> <head>
> <style type="text/css">
> #map_canvas { width: 450px; height: 450px; }
> </style>
>
> <script type="text/javascript"
> src="${pageContext.request.contextPath}/dwr/engine.js"></script>
> <script type="text/javascript"
> src="${pageContext.request.contextPath}/dwr/util.js"></script>
> <script type="text/javascript"
> src="${pageContext.request.contextPath}/dwr/interface/SessionService.js"></script> 
>
>  <script type="text/javascript"
> src="http://maps.google.com/maps/api/js?sensor=false [13]"></script>
>
> <script type="text/javascript">
> function initialize() {
> var latlng = new google.maps.LatLng(31, -92);
> var myOptions = {
> zoom: 8,
> center: latlng,
> mapTypeId: google.maps.MapTypeId.ROADMAP
> };
> var map = new
> google.maps.Map(document.getElementById("map_canvas"),myOptions);
> }
> </script>
> </head>
>
> <body onload="initialize()">
>
> <div id="map_canvas"></div>
>
> </body>
> </html>
>
>
>
> Links:
> ------
> [1] http://www.springframework.org/schema/beans
> [2] http://www.w3.org/2001/XMLSchema-instance
> [3] http://www.springframework.org/schema/p
> [4] http://www.springframework.org/schema/context
> [5] http://www.springframework.org/schema/util
> [6] http://www.springframework.org/schema/websocket
> [7] http://www.directwebremoting.org/schema/spring-dwr
> [8] http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
> [9]
> http://www.springframework.org/schema/context/spring-context-4.0.xsd
> [10] http://www.springframework.org/schema/util/spring-util-4.0.xsd
> [11]
> http://www.springframework.org/schema/websocket/spring-websocket-4.0.xsd
> [12] http://www.directwebremoting.org/schema/spring-dwr-3.0.xsd
> [13] http://maps.google.com/maps/api/js?sensor=false
Reply | Threaded
Open this post in threaded view
|

Re: Issue with DWR 3.0 Release and Google Maps API

Dmitry Gorodnitsky
In reply to this post by Dmitry Gorodnitsky
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Issue with DWR 3.0 Release and Google Maps API

david@butterdev.com
http://directwebremoting.org/dwr/documentation/server/configuration/servlet/index.html#generateDtoClasses

On 2015-10-03 08:28, Dmitry Gorodnitsky wrote:

> Found the root of the problem!
>
> Since the project is very complex, I created a smaller version with
> all technologies in place. And not surprisingly it was working fine.
> Then I the same exported service in both projects and found that the
> service that I use in production project contains ALL domain objects
> from ALL other services, where as test service doesn't. So the same
> service in test project and production project are different. 
> I created a static JS service file and started removing domain objects
> one by one. 
> The offending name was Image. Apparently it somehow breaks the Google
> Map API.
> I changed the mapping in @DataTransferObject to "Img" and everything
> started to work.
>
> Now my question is to DWR developers - why every JS service file drags
> ALL domain objects from ALL other services? I believe that there
> should be a way to remove unrelated domain objects from exported
> services. 
>
> Thanks,
>
> Dmitry
>
> P.S. The offending entry in service that was breaking compatibility
> with Google Maps API
>
>   if (!dwr.engine._mappedClasses["Image"]) {
>     c = function() {
>       this.updatedBy = null;
>       this.fileTransfer = null;
>       this.created = null;
>       this.format = null;
>       this.name [1] = null;
>       this.width = null;
>       this.id [2] = null;
>       this.updated = null;
>       this.content = null;
>       this.height = null;
>     }
>     c.$dwrClassName = 'Image';
>     c.$dwrClassMembers = {};
>     c.$dwrClassMembers.updatedBy = {};
>     c.$dwrClassMembers.fileTransfer = {};
>     c.$dwrClassMembers.created = {};
>     c.$dwrClassMembers.format = {};
>     c.$dwrClassMembers.name = {};
>     c.$dwrClassMembers.width = {};
>     c.$dwrClassMembers.id = {};
>     c.$dwrClassMembers.updated = {};
>     c.$dwrClassMembers.content = {};
>     c.$dwrClassMembers.height = {};
>     c.createFromMap = dwr.engine._createFromMap;
>     dwr.engine._setObject("Image", c);
>     dwr.engine._mappedClasses["Image"] = c;
>     addedNow["Image"] = true;
>   }
>
> Links:
> ------
> [1] http://this.name
> [2] http://this.id
Reply | Threaded
Open this post in threaded view
|

Re: Issue with DWR 3.0 Release and Google Maps API

Mike Wilson
Administrator
In reply to this post by Dmitry Gorodnitsky
> Now my question is to DWR developers - why every JS service file drags
> ALL domain objects from ALL other services? I believe that there should
> be a way to remove unrelated domain objects from exported services. 
 
As you see in the link David posted this is configurable. The reason for doing as you describe as default is to provide backwards compatibility with older versions of DWR.
 
But as you mention that you have a lot of domain objects exposed in the client, I would like to point out that usually you don't have to generate any domain classes at all in the client. If you skip the javascript="xyz" attribute on DataTransferObject annotations, objects of these classes are still transferred back and forth to the client but without generating a JavaScript class. Typically you only use classes in the client when you need polymorphism and similar. See http://directwebremoting.org/dwr/documentation/server/configuration/dwrxml/converters/bean.html#mappingJavaToJavaScript
 
Best regards
Mike Wilson
 
Dmitry Gorodnitsky wrote:
Found the root of the problem!

Since the project is very complex, I created a smaller version with all technologies in place. And not surprisingly it was working fine. Then I the same exported service in both projects and found that the service that I use in production project contains ALL domain objects from ALL other services, where as test service doesn't. So the same service in test project and production project are different. 
I created a static JS service file and started removing domain objects one by one. 
The offending name was Image. Apparently it somehow breaks the Google Map API.
I changed the mapping in @DataTransferObject to "Img" and everything started to work.

Now my question is to DWR developers - why every JS service file drags ALL domain objects from ALL other services? I believe that there should be a way to remove unrelated domain objects from exported services. 

Thanks,

Dmitry

P.S. The offending entry in service that was breaking compatibility with Google Maps API

  if (!dwr.engine._mappedClasses["Image"]) {
    c = function() {
      this.updatedBy = null;
      this.fileTransfer = null;
      this.created = null;
      this.format = null;
      this.name = null;
      this.width = null;
      this.id = null;
      this.updated = null;
      this.content = null;
      this.height = null;
    }
    c.$dwrClassName = 'Image';
    c.$dwrClassMembers = {};
    c.$dwrClassMembers.updatedBy = {};
    c.$dwrClassMembers.fileTransfer = {};
    c.$dwrClassMembers.created = {};
    c.$dwrClassMembers.format = {};
    c.$dwrClassMembers.name = {};
    c.$dwrClassMembers.width = {};
    c.$dwrClassMembers.id = {};
    c.$dwrClassMembers.updated = {};
    c.$dwrClassMembers.content = {};
    c.$dwrClassMembers.height = {};
    c.createFromMap = dwr.engine._createFromMap;
    dwr.engine._setObject("Image", c);
    dwr.engine._mappedClasses["Image"] = c;
    addedNow["Image"] = true;
  }