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/82ee7572-b3ab-445e-a07f-38b209aec3dcn%40googlegroups.com.