Zk how to call Java method from javascript?

asked 2016-10-24 10:04:43 +0800

psingh gravatar image psingh flag of India
963 8

updated 2016-10-24 17:15:25 +0800

I am using dropupload and browse functionality to upload the file. I am checking for maximum file size in both the functionalities. In case if the file size exceeded I want to call my java method to show the error message

In ZUL File

<dropupload maxsize="51200" id="fileUpload"></dropupload>

<script defer="true">
        var status = false;
        var oldAlert = jq.alert;
        jq.alert = function (msg, opts) {
            if (!msg.indexOf('the request was rejected because its size')){
                     status = true;

                //oldAlert(msg, opts);
                status = true;

            if (status) {
                zAu.send(new zk.Event(zk.Widget.$('#fileUpload'), 'onDropFile', status, {toServer:true}));


In View Model,

@Listen("onDropFile = #fileUpload")
public void onDropFile( Event evt) {
    if (evt.getData() != null) {
        showError("Upload File size is exceeded"); 


Can anyone how this functionality will work out or is there any other way to call java method from ZUl file using JAVASVRIPT?

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted

answered 2016-10-24 13:19:19 +0800

Darksu gravatar image Darksu
1991 1 4

Hello psingh,

You can refer to this old post:


Best Regards,


link publish delete flag offensive edit


The above given javascript function calls only when the uploaded file is greater than 51200 and then ZK error message is popped up. I am catching the error message and wants to call the java method from this function. But in my case, I am not able to call the method from this javascript function.

psingh ( 2016-10-24 17:11:34 +0800 )edit

Is there any other way to call the java method from this override error message?

psingh ( 2016-10-24 17:13:03 +0800 )edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

1 follower



Asked: 2016-10-24 10:04:43 +0800

Seen: 54 times

Last updated: Oct 24 '16

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More