I have a class which implements interface, I need to call that method from JSNI in GWT.see the below code,
interface:
public interface HeaderFormatter {
String format(String value);
}
class:
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
}-*/;
}
You can do it like this:
public static native void grouping(HeaderFormatter hf) /*-{
var value = // some String
var result = hf.@path.to.interface.HeaderFormatter::format(Ljava/lang/String)(value);
}-*/;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.