Java 如何在GoogleWebToolkit(GWT)中从JSNI调用接口(实例化)

Java 如何在GoogleWebToolkit(GWT)中从JSNI调用接口(实例化),java,javascript,gwt,Java,Javascript,Gwt,我有一个实现接口的类,我需要从GWT中的JSNI调用该方法 接口: 类别: 您可以这样做: public static native void grouping(HeaderFormatter hf) /*-{ var value = // some String var result = hf.@path.to.interface.HeaderFormatter::format(Ljava/lang/String)(value); }-*/; public GWTGroupi

我有一个实现接口的类,我需要从GWT中的JSNI调用该方法

接口:

类别:


您可以这样做:

public static native void grouping(HeaderFormatter hf) /*-{
   var value = // some String 
   var result = hf.@path.to.interface.HeaderFormatter::format(Ljava/lang/String)(value);
}-*/;
 public GWTGrouping implements HeaderFormatter {

    public String format(String value){
      return "<span><i class='fa fa-stop'></i></span>";
    }
    public void performGrouping(){
        if(isgroup){
          grouping();
        }  
    }

    public static native void grouping() /*-{
    //dont want to pass whole class to this method (this)
    //Need to access format(String value) Method which will return some logic
    //How to access that method here by passing interface not whole class
    }-*/;

}
public static native void grouping(HeaderFormatter hf) /*-{
   var value = // some String 
   var result = hf.@path.to.interface.HeaderFormatter::format(Ljava/lang/String)(value);
}-*/;