Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    problem when trying to call JavaMethod from Javascript using JSNI

    Hi,

    I am using smartgwt 2.5 PRO and smartclient 8.1
    with GWT 2.4 Browser FF: 12.0

    In my application I am creating a external HTML File to show a Map. Now I am setting this .HTML file in HTMLPane. I have a SAVE Button on HTML MapInfoWindow (using <INPUT>).

    Now my requirement is when user clicks on the SAVE Button I need to get the lat/lng from the Map and pass these to my client side Java Method in order to geocode the address and set the values in the Window Fields.

    I am using JSNI in order to call JavaMethod from my External HTML File onclick even of SAVE Button.

    Map.HTML
    Code:
    <input type="button" value="Save" onclick="clickedSaveButton(ll.getLatitude(),ll.getLongitude())">
    
    function clickedSaveButton(lat, lng) 
    {
    	getMyLatLng(lat, lng);
    	alert(lat);
    	map.dispose();
    }
    ClientSide Java File Presenter.java
    Code:
    public static native void exportCallToGetLatLng() 
    /*-{
    	$wnd.getMyLatLng = $entry(function(lat,lng)
      	{
      		alert('first '+lng);
    		@in.systemintegration.client.presenter.LoadPresenter::callToGetLatLng(Ljava/lang/String;Ljava/lang/String;)(lat,lng);
    	});	
    }-*/;
    
    public static void callToGetLatLng(String lat, String lng)
    {
    	String currentLat = lat;
    	String currentLng = lng;
    	SC.say("JAVA Variable Values :: "+currentLat+" ************* "+currentLng);
    	callme(currentLat,currentLng);
    }
    
    public static void callme(String currentLat,String currentLng)
    {
    	SC.say("inside callme !! ");
    	Criteria criteria = new Criteria();
    	criteria.setAttribute("currentLat",currentLat);
    		criteria.setAttribute("currentLng",currentLng);
    		criteria.setAttribute("isLocationMap","true");
    		DataSource loadDMI = DataSource.get(LOAD_DMI);
    		loadDMI.fetchData(criteria, new DSCallback() 
    	{
    		@Override
    		public void execute(DSResponse response, Object rawData, DSRequest request) 
    		{
    			String prop=response.getAttributeAsString("done");
    			if(prop.equals("true"))
    			{
    				SC.say("Got a CallBackResponse From LOADSDAO !!! ");
    			}
    		}
    	});
    }
    Now my JSNI Method works perfects returns me the correct lat/lng means I get the SC.say("inside callme !! ");. But after that the simple GWT code to send criteria on ServerSide does not get executed. I think it only allows JS code to run.

    I dont know where I am wrong. Any Help will be greatly appreciated
Working...
X