-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I have hunted through the forums and documentation, and apologize since I know I should have been able to figure this out, but have had no luck so far.
I have read all the docs related to this already, so please don't refer me to them. I am looking for a simple working example.
I want to call a method on a GenericForwardComposer class from within javascript in my zul file. The javascript is actually being called from an Ipad app, so I can't call it from within my <window> or any other zul object to help get a reference to the window object. I need to make the call to the server from purely within javascript. I don't have to pass any data, I just need that call on the server made.
The method on the server is shown below "callCleanup", I just want to call this from within a javascript function.
My java file is :
public class DHzHomeView extends DHzGenericForwardComposer { public void callCleanup(Event event) { .... } ... }
My zul file is :
<script type="text/javascript"> function callCleanup() { /* THIS CALL DOES NOT WORK */ zAu.send(new zk.Event(zk.Widget.$(jq('$_homeWindow')[0]), 'callCleanup', null, {toServer:true})); } </script> window id="_homeWindow" border="normal" apply="com.dh.ui.ipad.view.DHzHomeView" height="100%" width="100%">
I managed to get the send to work (at least it appears to be via firebug) with the following call in javascript.
What I need now is how to catch this on the server in my GenericForwardComposer class?
function callCleanup() { var windowWidget = zk.Widget.$('$_homeWindow'); zAu.send(new zk.Event(windowWidget, 'onCleanup',null)); }
I figured this out myself finally, here is how you do it :
If you are using GenericForwardComposer as I described above, simply define a method in the java class that matches the name used in the zAu.send call :
zAu.send(new zk.Event(windowWidget, 'onCleanup',null));
public void onCleanup(Event event) { }
With the javascript code I show above in my previous posts - this java method in your GenericForwardComposer will get called if you call the javascript function "callCleanup".
Asked: 2012-06-19 12:52:41 +0800
Seen: 210 times
Last updated: Jun 19 '12