2

I am using Edraw Office Viewer component to open & edit the file. I want to save my file to my destination point so I am using JavaScript to save the file. But I am stuck at a point. I am showing my code below to save document using JavaScript.

function f_saveDocument(){
    if(document.OA1.IsOpened)           
    {   
    var saveAsFileName = document.getElementById('hdnFileName').value;
    alert(saveAsFileName);
        var fileFormat = saveAsFileName.substring(saveAsFileName.lastIndexOf("."));
        if(fileFormat == '.docx') {
            var toUnLockFile = 'MergeTest'+fileFormat;
            var tempFileLocation = document.OA1.GetTempFilePath(saveAsFileName);
            var tempToUnLockFileLocation = document.OA1.GetTempFilePath(toUnLockFile);
            document.OA1.SaveAs(tempFileLocation,12);
            document.OA1.SaveAs(tempToUnLockFileLocation,12);
            document.OA1.HttpInit();
            document.OA1.HttpAddPostFile(tempFileLocation);
              document.OA1.HttpPost(""); 
            document.OA1.ClearTempFiles();
        } else {
        alert("asdsa");
            document.OA1.HttpInit();
            document.OA1.HttpAddPostOpenedFile(saveAsFileName);
             **zAu.send(new zk.Event(zk.Widget.$('$btnSave'), "saveFile", {'' : {'data' : {'nodeId': ''}}}, {toServer:true}));** 
         alert("moved");
        }

    } 

In case of JSP page I can put my JSP URL in HttpPost but in case of ZK how to move from this JavaScript to Java method. So to overcome this problem I am using Widget to call saveFile() method which is in my viewmodel class. But zAu.send is not working fine. Can any body tell other solution to call my Java method from JavaScript in ZK MVVM.

1 Answer 1

4

Your code is simply wrong

zAu.send(new zk.Event(zk.Widget.$('$btnSave'), "onSaveFile", {'' : {'data' : {'nodeId': ''}}}, {toServer:true}));

Event names must start with on so this will fire a onSaveFile
event to the Component with id btnSave. Just listen to it.

Sign up to request clarification or add additional context in comments.

1 Comment

Nabil: I have one more Question...Is there any way to pass zk url in HttpPost?Actually I want to get request in java method for MultipartRequest. MultipartRequest mr = new MultipartRequest(request, savePath, 50000000);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.