-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I want to implement digital signature method:
1,press button to call java logic in server which caculate the whole datas
2,call the Java script in client which get the digital signature
3,store the result into database in server.
Of course it has no return value, this method will just add this JS to the response of the current execution. The JS will be rendered and executed at the client side.
I just adapted the example from above and added the remaining steps: see here
As you can see the result of the doClientSignature function is passed to the server in a separate command "storeToDB"
Also check the network tab in firebug or in chrome developer tools... you'll see that 2 ajax requests are made to the server. One with the onClick event, and the second with the custom onStore event. The server translates these events into the appropriate commands defined in the MVVM command bindings.
I hope that clarifies your questions.
If not, please let me know.
Robert
for 1 you simply fire a command to the server
<button onClick="@command('calculate')" label="click me" />
and for 2 you implement a command handler in your ViewModel and call Clients.evalJavaScript()
@Command("calculate")
public void onCalculate() {
//your calculations
Clients.evalJavaScript("someScriptFunction();")
}
and 3 fire an event back to the server using the ZK Client API
http://books.zkoss.org/wiki/SmallTalks/2010/April/ClientSideProgramming#Communicateto_Server
Here is also a running example... "button three" shows you all your 3 steps (be aware that the onClick code is executed at the server side)
This example will send 2 events to the server... an onClick event, and an onTest event, with a server roundtrip in the middle.
The data sent with the last event you can then save into the database, of your choice
Asked: 2013-08-25 04:40:35 +0800
Seen: 167 times
Last updated: Aug 26 '13
Facing issue in masking on phone [closed]
coerceFromString_ override no longer works from 6.5.1 [closed]
Execute Javascript on component visible
Is there a way to resolve view model properties as input to client side javascripts?
scrollbar listner for 2 grid [closed]
Theme javascript wpd file not found