Pero
Pero

Reputation: 794

How to create an instance of an interface in GWT?

How can i create an instance of an interface ? example

@Connection(name="ClckCnt", version="1.0", description="Click Counter", maxsize=10000) 
public interface MyInterface extends DataService{


    @Update("CREATE TABLE IF NOT EXISTS clickcount ("
      + "id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "
      + "clicked INTEGER)")
  void initTable(VoidCallback callback);


     @Update("INSERT INTO clickcount (clicked) VALUES ({when.getTime()})")
  void insertClick(Date when, RowIdListCallback callback);
}

public class WebApp implements EntryPoint{

    MyInterface myInterface = GWT.create(MyInterface.class);

    public void onModuleLoad(){

    }
}

This kind of example i have from the gwt-html5-database project. in this project is a sample application and they did it the same way but it doesnt work. Somebody have an idea? Greets.

Upvotes: 0

Views: 356

Answers (1)

Thomas Broyer
Thomas Broyer

Reputation: 64541

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

You can either provide concrete implementations and chose the one to use depending on some properties (including, for example, user agent and/or locale), or use a generator. you can combine both: use a concrete implementation in some case, and a generator in another, depending on properties.

Upvotes: 2

Related Questions