Monday, June 30, 2014

Fwd: [gwt-contrib] Questions about @JsProperty and JsType.prototype()

When i translate a pure java library to a javascript library using JsInterop, i get confused about @JsProperty and JsType.prototype().

The java code looks like this:
public class TextInsertedEvent {

   * The index of the change.

public final int index;
   * The inserted text

public final String text;

   * @param serialized The serialized event object.

TextInsertedEvent(JsonObject serialized) {
this.index = (int) serialized.getNumber("index");
this.text = serialized.getString("text");

public int index() {
return index;

public String text() {
return text;

This TextInsertedEvent class is not allowed to be instantiated directly in javascript, so do not need to export its constructor.

When someone using the translated js library in a pure javascript web application:

1. How to prevent the prototype name from obfuscated?
e.g. should returns true
evt is a TextInsertEvent instance created from the translated library

2. How to translate to dotted property accessor instead of method calls?
e.g. enable users to call evt.text to get the actual string value, not evt.text()

Thanks for help :)

You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
For more options, visit

No comments:

Post a Comment