Tuesday, October 29, 2013

Re: JNI Problem

You are missing an extra () it should read:
var colorScale = p_valHolder.@com.ll.cidb.client.CIDBViewer::getColorScale()();



On Tue, Oct 29, 2013 at 4:58 PM, Sean <sloughran@gmail.com> wrote:
Hey guys, I read the documentation on JNI and I think what I'm doing is correct, but its not working. I'm trying to get values from JAVA into Javascript. 

Code Snippet:
[...]
/**
* @return
*/
public String getColorScale()
{
int selIndex =m_colorBox.getSelectedIndex();
return m_colorBox.getItemText(selIndex);
}

/**
* @return TMS URL for OSM cyclemap
*/
private static native JSObject getCIDBUrl(CIDBViewer p_valHolder) /*-{
function get_my_gwt_url(bounds) {
var res = this.map.getResolution();

var x = Math.round((bounds.left - this.maxExtent.left)
/ (res * this.tileSize.w));
var y = Math.round((this.maxExtent.top - bounds.top)
/ (res * this.tileSize.h));
var z = this.map.getZoom();
if(z<12)
{
}
var left = bounds.left;
var right = bounds.right;
var top = bounds.top;
var bottom = bounds.bottom;
//Call the JAVA side to get these values
var minVal = 0;
var maxVal = 10;
var colorScale = p_valHolder.@com.ll.cidb.client.CIDBViewer::getColorScale();
+ "&left=" + left + "&right=" + right + "&top=" + top
+ "&bottom=" + bottom
+"&cs="+ colorScale
+"&min="+minVal
+"&max="+maxVal;
return url;
}

return get_my_gwt_url;
}-*/;

[...]


So you can see I have a simple java method that gets the value out of a ListBox. I want to pass that value into the JavaScript function so I can send it to my server. However, when I get to the server the value of colorScale is:
[function () {      var result = __static(dispId, this);      if (result[0]) {        throw result[1];      } else {        return result[1];      }    }]


I've tried this instead of passing the java instance. That didn't work either.

Any ideas?

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment