0

I'm writing a GWT application and I need to pass an array of java objects into JavaScript (or convert such array to JS array), I'm very new to JSNI and wondering if it's possible to do. For example :

public class EntityBase {

    private String id;

    private String name;

    public EntityBase(int id) {
        this.id = id;
    }
}

and I have an array of such objects...can I pass them correctly? If not, what will you suggest me to do? Thanks for any help.

2 Answers 2

3

You can use GSON to encode and decode objects.

As alternative, you can use AutoBeans.

I use AutoBean, but GSON may have less overhead for you. You may need to add a Default Constructor (without parameter) and get/set Methods.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for advice to use GSON, it was exactly what I was looking for
Note that you cannot use GSON on the client side of GWT.
At clientside I would use AutoBeans
0

You might try using GWT Overlay concepts with Lightweight collections

https://developers.google.com/web-toolkit/doc/latest/DevGuideCodingBasicsOverlay

Example - http://googlewebtoolkit.blogspot.in/2008/08/getting-to-really-know-gwt-part-2.html

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.