Tuesday, January 2, 2018

Returning an array of objects to javascript via JsInterop - how?

I have a class which is just a data storage object

public class Product{ 
int id;  
String name;
public Product()
public int getId() {
return id;
public void setId(int id) {
this.id = id;
public String getName() {
return name;
public void setName(String name) {
this.name = name;

I have another class that will be used to process data and will have a method to return an array of Product objects based on the processing.

public class Processor {
public Product[] doStuff()

My goal is to use JsInterop to make the doStuff() method available to other javascript on a site.

Is this as simple as putting the @JsType annotation at the top of both of these classes?  If so, does GWT handle the conversion of the array of Java Product objects into an array of javascript Product objects or is there something else that needs to be done?

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 post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment