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/3f012142-925d-4e91-bc54-4d201a20c9aan%40googlegroups.com.

Reply via email to