Thursday, June 11, 2020

Re: GWT Super devmode is not working for me

In GWT 2.7.0 (specifically in the first release candidate), SDM was made the default, and IFrameLinker, XSLinker were deprecated since they didn't work properly with SDM. You can reenable them in your own project though. However, the replacement linker is mentioned in the release notes as having some limitations, especially around <script> tags in your .gwt.xml file. [1]

An issue was filed to track limitations in this new linker. [2] [3]

There is also another discussion that was started around the same thing. [4] [5]

---

As I understand it, there are two main ways to support this case now: either include those scripts in your initial .html file that loads your GWT module, or use ScriptInjector [6] to load each script that you want to run. Moving the <script> tags to your html file and placing them before your .nocache.js script tag has the advantage of completely keeping them out of code and letting you reference them directly, whereas ScriptInjector has other benefits: if you don't need the files right away, you can defer loading them until just before you need them, and can listen to callbacks to indicate that they are loaded. ScriptInjector also has a mechanism by which you can pass the full string of the script's contents rather than a file, so that you can include the script in your .cache.js output, instead of making each file load individually without "perfect caching" [7], adding a bit of delay to your app startup. This would be achieved through creating TextResources or ExternalTextResources in a ClientBundle [8].

One word of caution: you probably are relying on those script files being included into your main page (rather than the GWT iframe), so you will probably need to include a call to .setWindow(ScriptInjector.TOP_WINDOW) when you make up the ScriptInjector call, so that your JSNI correctly references this code.

In either case, the .js file needs to be where the app can load it. In GWT, this usually means creating a public/ directory in the same package as your client/ and your .gwt.xml file. Then, the URL you pass to ScriptInjector should be prefixed with GWT.getModuleBaseForStaticFiles() so that it loads correctly. For example, if you created a com/myproject/public/sc/modules/ISC_Core.js file in your sources, you could reference it as:

ScriptInjector.fromUrl(GWT.getModuleBaseForStaticFiles() + "sc/modules/ISC_Core.js")
    .setWindow(ScriptInjector.TOP_WINDOW)
    .setCallback(...)
   .inject();

or, in the main html page as <script src="App/sc/modules/ISC_Core.js"></script>.
Since you've mentioned SmartGwt, I'm guessing that these files are already in a public/ directory inside a SmartGWT jar, and you can skip this last section.


[1] http://www.gwtproject.org/release-notes.html#Release_Notes_2_7_0_RC1
[2] https://code.google.com/archive/p/google-web-toolkit/issues/8997 which was moved to github:
[3] https://github.com/gwtproject/gwt/issues/8951
[4] https://code.google.com/archive/p/google-web-toolkit/issues/9016
[5] https://github.com/gwtproject/gwt/issues/8970
[6] http://www.gwtproject.org/javadoc/latest/com/google/gwt/core/client/ScriptInjector.html
[7] http://www.gwtproject.org/doc/latest/DevGuideCompilingAndDebugging.html#perfect_caching
[8] http://www.gwtproject.org/doc/latest/DevGuideClientBundle.html#TextResource

On Thursday, June 11, 2020 at 10:13:09 AM UTC-5, ruwan samaraweera wrote:
Hi,
I'm using gwt since so many years back. To debug my application those days I've used gwt devmode. But now the plugin is not support in modern browser(Im using lates version of Chrome). So I tried to used super devmode. But unfortunately I couldn't able to configure it correct way. It is given many errors and I cant debug my application.  
Actually Im developing web application using gwt 2.6.1 and java 1.8 and deploying it in tomcat9 webserver.
My configuration as follows.

gwt.xml file
--------------

<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='App'>

<inherits name="com.google.gwt.user.User" />
<!--<inherits name="com.smartgwt.SmartGwt"/>-->
<inherits name="com.smartgwt.SmartGwtNoTheme" />
<inherits name="com.smartgwt.SmartGwtNoScript"/>
<inherits name="com.smartgwtee.SmartGwtEENoScript"/>

<inherits name="com.smartgwt.Drawing"/>
<inherits name="com.smartgwt.Charts"/>
<inherits name="com.smartgwtee.tools.Tools"/>
<inherits name="com.smartgwt.Analytics"/>
<stylesheet src='../pages/resources/mmv-style.css'/>
<inherits name="com.smartclient.theme.enterpriseblue.EnterpriseBlue" />
<inherits name="com.smartclient.theme.enterpriseblue.EnterpriseBlueResources"/>
<inherits name='com.google.gwt.visualization.Visualization'/>

<entry-point class="mywebapp.client.AppEntryPoint" />

<source path="client"/>
<source path="shared"/>

<add-linker name="xsiframe"/>

<set-configuration-property name='xsiframe.failIfScriptTag' value='FALSE'/>

<extend-property name="locale" values="en" />

<!-- Following should exist only in Development mode-->
<!--<inherits name="com.smartgwt.tools.SmartGwtTools" />-->
<set-property name="user.agent" value="safari" />

</module>

Hear I've add xsiframe linker and other configuration tag as well
Apart from that I've added following tags in my host page.

script src="App/sc/modules/ISC_Core.js"></script>
<script src="App/sc/modules/ISC_Foundation.js"></script>
<script src="App/sc/modules/ISC_Containers.js"></script>
<script src="App/sc/modules/ISC_Grids.js"></script>
<script src="App/sc/modules/ISC_Forms.js"></script>
<script src="App/sc/modules/ISC_RichTextEditor.js"></script>
<script src="App/sc/modules/ISC_Calendar.js"></script>
<script src="App/sc/modules/ISC_DataBinding.js"></script>
<script src="App/sc/modules/ISC_Drawing.js"></script>
<script src="App/sc/modules/ISC_Charts.js"></script>
<script src="App/sc/modules/ISC_Analytics.js"></script>
<script src="App/sc/skins/SilverWaveX/load_skin.js"></script>

Im using ant target to build application and making war file and place it tomcat9. So same way Im using ant target to run superdevmode as follows.

<target name="superDevMode" description="Run GWT debug mode">
<java failonerror="true" fork="true" classname="com.google.gwt.dev.codeserver.CodeServer">
<classpath>
<fileset dir="${proj.gwt.debug.sdk}" includes="*.jar" />
<path refid="project.class.path" />
</classpath>
<jvmarg value="${proj.runtime.initmemory}" />
<jvmarg value="${proj.runtime.maxmemory}" />
<jvmarg value="${proj.runtime.permgensize}" />
<jvmarg value="-Xdebug" />
<jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=${proj.gwt.debug.client.debug.port}" />
<!--<arg value="-noserver" />-->

<arg value="-port" />
<arg value="${proj.gwt.debug.server.http.port}" />
<!--<arg value="-startupUrl" />-->
<!--<arg value="/${proj.webapp.name}" />-->
<arg value="${proj.gwt.module}" />
</java>
</target>

 In properties.xml file

<!-- Following properties are used to GWT DEBUGGING -->  	<property name="proj.gwt.debug.sdk" location="D:Project\myApp\gwt\gwt-2.6.1" />  	<property name="proj.gwt.debug.server.http.port" value="8080" />  	<property name="proj.gwt.debug.client.debug.port" value="5028" />

But when I'm running ant target it is giving following error
 [ERROR] The Cross-Site-Iframe linker does not support <script> tags in the gwt.xml files, but the gwt.xml file (or the gwt.xml files which it includes) contains the following script tags:
     [java]     at com.google.gwt.core.ext.linker.impl.SelectionScriptLinker.generateSelectionScript(SelectionScriptLinker.java:422)
     [java] sc/modules/ISC_Core.js
     [java]     at com.google.gwt.core.ext.linker.impl.SelectionScriptLinker.emitSelectionScript(SelectionScriptLinker.java:309)sc/modules/ISC_Foundation.js
     [java]
     [java] sc/modules/ISC_Containers.js
java]     at com.google.gwt.dev.codeserver.CodeServer.makeModules(CodeServer.java:120)In order for your application to run correctly, you will need to include these tags in your host page directly. In order to avoid this error, you will need to remove the script tags from the gwt.xml file, or add this property to the gwt.xml file: <set-configuration-property name='xsiframe.failIfScriptTag' value='FALSE'/>       [java]       [java]     at com.google.gwt.dev.codeserver.CodeServer.start(CodeServer.java:95)

It is great if some one can help me on this.

Thanks

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/fd1fb5a9-5d98-4b93-a878-dc3cd24dc427o%40googlegroups.com.

No comments:

Post a Comment