You can read more about Apache Wicket here
Here let us check how to invoke Javascript from a Wicket component and how receive/handle response. Assume the requirement is having a webpage where we will load some control using Javascript(For example - Google Earth ;) ) , and once the javascript execution is completed the page should do something.
01 public class MyPage extends WebPage { Here we are creating a webpage and adding a panel to that. The panel is the place where we will |
But before going to the panel let us check how to get a call back from the JavaScript.
For acheiving this we will add an AjaxBehavior to the panel
01 public MyPage() { |
Curresponding html files are simple enough.
Now lets look at the JSPanel. Here we need to call the javascrip onLoad of the page. This is acheived through RenderHead method.
|
Lets look at the relevant javascript now
function init(urlVal) {
url = urlVal;
//
//Create an instance of GE.
google.earth.createInstance("map3d", initCallback, failureCallback);
}
function initCallback(object) {
//
// Show GE and move camera to decired location.
ge = object;
ge.getWindow().setVisibility(true);
var lookAt = ge.getView().copyAsLookAt(ge.ALTITUDE_RELATIVE_TO_GROUND);
...
ge.getView().setAbstractView(lookAt);
...
//
// Make a call to the wicket callback url from here
var arg = "&key=" + value;
var wcall = wicketAjaxGet(url + arg , function() { }, function() { });
}
That is it. Let me know if you need the complete sample code for this.
Java code displayed as html here is using a tool HTML4Java, you can check it here http://www.toolbuddy.org/html4java.htm
google earth + wicket = planet wicket.
ReplyDeletesick, man, sick!
good one , thank you
ReplyDelete