[英]Codename one BrowserComponent setBrowserNavigationCallback
I am trying to use the 我正在尝试使用
setBrowserNavigationCallback
setBrowserNavigationCallback
method of the BrowserComponent to call a java method from the html page. BrowserComponent的方法,以从html页调用Java方法。
This is what I have in java: 这就是我在java中的功能:
map_browser = (BrowserComponent) this.getInternal();
map_browser.setBrowserNavigationCallback(new BrowserNavigationCallback() {
public boolean shouldNavigate(String url) {
System.out.println("in here::" + url);
if (url.startsWith("http://getproperties")) {
System.out.println("get properties from java code 1");
return false;
} else {
return true;
}
}
});
The code on html is: html上的代码是:
<a href="http://getproperties">Load</a>
This works fine. 这很好。 When I click on Load, the shouldNavigate() gets invoked.
当我单击Load时,shouldNavigate()被调用。
However, this works only once. 但是,此操作仅一次。 If I click on Load again, nothing happens...
如果我再次单击“加载”,则什么也不会发生...
Is this the expected behavior ? 这是预期的行为吗?
If yes, what is the best way to achieve calling a java function multiple times from javascript ? 如果是,从javascript多次调用java函数的最佳方法是什么?
Am I doing something wrong ? 难道我做错了什么 ?
BR, Sanket BR,桑凯
This causes the location for the browser to change which then means that further navigation won't occur. 这将导致浏览器的位置发生变化,这意味着不再进行导航。 Try using myprotocol://getproperties which won't go into the location of the browser and should be fired repeatedly.
尝试使用myprotocol:// getproperties,它不会进入浏览器的位置,应该被反复触发。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.