unable to resolve method in class

794 Views Asked by At

1.is it possible to call the native method in the gwt into the other native method ?

this is the method i am calling from the VectorSource.java into Map.java https://github.com/VOL3/v-ol3/blob/master/gwt-ol3/src/main/java/org/vaadin/gwtol3/client/source/VectorSource.java

 public final native JsArray<Feature> getFeatures()/*-{
        return this.getFeatures();
    }-*/;

and i created a native method in Map.java class and getting the Features and i want to return these feature values to addOnPostRenderListener method below are the changes in the Map.java class

    public native final Feature getFeatures(VectorSource sourceFeature)/*-{
    var features=sourceFeature.@org.vaadin.gwtol3.client.source.VectorSource::getFeatures();
    return features;
    }-*/;


    public native final void addOnPostRenderListener(OnPostRenderListener listener)/*-{


       if(!this.__registered){
       var that=this;

       that.once('postrender',function(){
        var [email protected]::getFeatures(vectorSource);
        if(feature!=null){
        var coordinate=feature.getGeometry().getCoordinate();
        if(coordinates!=null){
        var MapEvent={Pixel:that.getPixelFromCoordinate(that.__transformInputCoordinate(coordinates))};
        that.__notifyPostRenderListeners(MapEvent);
        }
        }})
        this.__postRenderListeners.push(listener);
        }
    }-*/;

the remaining code remains the same as shown in the below link https://github.com/VOL3/v-ol3/blob/master/gwt-ol3/src/main/java/org/vaadin/gwtol3/client/Map.java

at the below code i am getting the error,as Expected a valid parameter type signature in JSNI method reference these lines of code is in the addOnPostRenderListener method

 var [email protected]::getFeatures(vectorSource);

my target is to call the method getFeatures() from VectorSource.java class into the Map.java class and send the values to the other native method which is addOnPostRenderListener method.

Interface

public interface OnPostRenderListener {

    public void onRender(MapEvent posEvent);
}

MapEvent

public class MapEvent extends JavaScriptObject {


    protected MapEvent() {

    }


     public static final native Feature create()/*-{
     return new $wnd.ol.Feature();
      }-*/;


     public native final Geometry getGeometry()-{
        return this.getGeometry();
       }-;*/


    public native final Geometry getGeometry()/*-{
        return this.geometry;
    }-*/;

    public native final Coordinate getCoordinate()/*-{
    return this.coordinate;
     }-*/;


   public native final Pixel getPixel()/*-{
    return this.Pixel;
    }-*/;

   //written code not used 
   public native final Map getPixelFromCoordinate(Coordinate coord)/*-{
     return this.getPixelFromCoordinate(coord);
    }-*/;
}
1

There are 1 best solutions below

7
Halko Karr-Sajtarevic On

You need to pass your VectorSource sourceFeature parameter too. You are missing it in [email protected]::getFeatures(Lcom/google/gwt/core/client/Source;);.

One way to do this, would be add it to your

addOnPostRenderListener(OnPostRenderListener listener)

e.g. addOnPostRenderListener(OnPostRenderListener listener, VectorSource vectorSource)

and then to access it like this:

var [email protected]::getFeatures(vectorSource);

Although I would recommend to completely drop JSNI and use the much better JsInterop. There is an OL-implementation using JsInterop too. Take a look here