Yes it worked. The issue was with the -generateJsInteropExports flag only. 
I added it inside my pom and it worked as expected.

<plugin>
          <groupId>net.ltgt.gwt.maven</groupId>
          <artifactId>gwt-maven-plugin</artifactId>
          <version>1.1.0</version>
          <extensions>true</extensions>
          <configuration>
            <sourceLevel>11</sourceLevel>
            <compilerArgs>
              <arg>-generateJsInteropExports</arg>
            </compilerArgs>
            <useCompilerArgsForTests>true</useCompilerArgsForTests>
            <codeserverArgs>
              <arg>-generateJsInteropExports</arg>
            </codeserverArgs>
            <devmodeArgs>
              <arg>-generateJsInteropExports</arg>
            </devmodeArgs>
            <failOnError>true</failOnError>
          </configuration>
        </plugin>

Thank you so much for your time, much appreciated Sir.

On Monday, August 26, 2024 at 8:44:02 PM UTC+5:30 Colin Alworth wrote:

> It isn't clear to me which maven plugin uses that property (
> https://gwt-maven-plugin.github.io/gwt-maven-plugin/compile-mojo.html#generateJsInteropExports
>  
> shows that the old plugin would support 
> -Dgwt.compiler.generateJsInteropExports=true, 
> and I think https://tbroyer.github.io/gwt-maven-plugin/compile-mojo.html 
> would expect the flag to be listed as each a compiler arg, 
> codeserver/devmode arg, and passed as part of gwt.args to tests), but if it 
> is working now, that was the issue.
>
> GWT doesn't default to exporting every non-native jsinterop type and 
> member as this increases code size - each of these becomes and entrypoint, 
> which can prevent the compiler from obfuscating some names, rewriting 
> method signatures or pruning members, and can limit what code can be moved 
> to split points. So, you must opt-in to this feature, and adding this flag 
> is part of the requirements for that.
>
> Odds are that you can add that flag to your pom.xml directly in the plugin 
> configuration, so you need not list it from the command line.
>
> On Monday, August 26, 2024 at 10:08:06 AM UTC-5 Corbett Tek wrote:
>
>> I did tried to compile my project using -generateJsInteropExports by
>>
>> mvn -DgenerateJsInteropExports=true compile package
>>
>> Then again started the server and client... but it did worked.
>> I don't know what I am missing in this whole picture?  
>>
>> On Monday, August 26, 2024 at 8:21:47 PM UTC+5:30 Corbett Tek wrote:
>>
>>> Yes Sure, 
>>>
>>> I have a Home class that extends EntryPoint and onModuleLoad(), I 
>>> created a button which calls a native java Method who's implementation is 
>>> in js file. 
>>> This is that Js file, 
>>>
>>> window.Home = {
>>> getRevertName: function (name) {
>>>
>>> var test = new com.test.jsinterop.Entity(1,'test');
>>> return name + test.getName();
>>> }
>>> }
>>>
>>> this works file when I am simply returning some text. But when I am 
>>> calling the previously mentioned Entity class from this Js method it is 
>>> throwing an error. What I want is to call the Entity from my js file.
>>>
>>> I am not sure how to add -generateJsInteropExports to the compiler. 
>>> Althrough I did put <set-configuration-property 
>>> name="generateJsInteropExports" 
>>> value="true"/>  in my module.gwt.xml file.
>>>
>>> Yes no problem with Integer or int. I did replaced all the instances of 
>>> Interger to int.
>>>
>>> On Monday, August 26, 2024 at 8:04:45 PM UTC+5:30 Colin Alworth wrote:
>>>
>>>> Can you share how you're using this from JS and what you expect to work 
>>>> here?
>>>>
>>>> Two quick notes:
>>>>  * Make sure you are passing the -generateJsInteropExports flag to the 
>>>> compiler
>>>>  * You almost certainly don't want to use `Integer` here, since there 
>>>> is no corresponding JS type for that. Instead, if know the caller will 
>>>> only 
>>>> pass integers, use `int`, if you want to support nulls, use boxed Double 
>>>> (which behaves the same as JS Number). Both Double and Boolean boxed Java 
>>>> types can be nullable when passed between JS and Java, but no other boxed 
>>>> primitives are supported in JS. 
>>>> On Monday, August 26, 2024 at 9:29:05 AM UTC-5 Corbett Tek wrote:
>>>>
>>>>> I am trying to access Java class from Js as per mentioned in the 
>>>>> JsInterop documentation, but getting errors like "ReferenceError: com is 
>>>>> not defined
>>>>>     at <anonymous>:1:9" or  "ReferenceError: Entity is not defined
>>>>>     at <anonymous>:1:9".
>>>>>
>>>>> Following is my Entity class and when I access it via java file or 
>>>>> console using 
>>>>> var test = new com.test.jsinterop.Entity(1,'test'); 
>>>>> it throws the errors.
>>>>>
>>>>> package com.test.jsinterop;
>>>>> import jsinterop.annotations.JsPackage;
>>>>> import jsinterop.annotations.JsType;
>>>>>
>>>>> @JsType(namespace = JsPackage.GLOBAL)
>>>>> public class Entity {
>>>>>
>>>>> public Integer id;
>>>>>
>>>>> public String name;
>>>>>
>>>>> public Entity(Integer id, String name) {
>>>>> this.id = id;
>>>>> this.name = name;
>>>>> }
>>>>>
>>>>> public Integer getId() {
>>>>> return id;
>>>>> }
>>>>>
>>>>> public void setId(Integer id) {
>>>>> this.id = id;
>>>>> }
>>>>>
>>>>> public String getName() {
>>>>> return name;
>>>>> }
>>>>>
>>>>> public void setName(String name) {
>>>>> this.name = name;
>>>>> }
>>>>> }
>>>>>
>>>>> How can I fix this? Can someone explain how this thing really works 
>>>>> i.e calling Java from js using JsInterop.
>>>>>
>>>>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-web-toolkit/467e7fbc-3fcb-476c-8ab1-0289dd72ab94n%40googlegroups.com.

Reply via email to