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.
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.
Related
I have single ajax application in java. I am working with lots of file type images. But some file has no extension or may be bed extension(Non-popular) in this case i replace with default image in "javascript".
Here I want to checkout at server side for each image request. and if image path not found then i want to replace with default image.
My existing scenario is below:
In Javascript
function getDefaultFileImageName(image){
image.onerror = "";
image.src = "Images/32px/_blank.png";
return true;
}
<img src='Images/32px/pdf.png' onerror='getDefaultFileImageName(this)' />
i have lots of images on page so in this case i get out put in firebug like this:
so i want server side-Java solution.
So if image not exist then server self return default image.
I believe this might be what you're looking for:
https://stackoverflow.com/a/3327673/2040509
$(".myimage").error(function(){
$(this).hide();
});
$(".myimage").load(function() {
$(this).show();
});
You need to remove onerror method from your function:
function getDefaultFileImageName(image){
image.src = "Images/32px/_blank.png";
return true;
}
$( document ).ready(function() {
$("#MyPicture").onerror = function () {
this.src = 'error.png'; // Error image
};
});
<img src='Images/32px/pdf.png' id="MyPicture" />
I am using nodejs, Soda with selenium
I am hitting problems trying to get the javascript to fire events like on entry of data. Script can't even get through the creation of client flow on IE. Only worried about IE 9+ btw.
Am I missing anything ? This works fine in latest FF. Below posting sample code using for FF
var soda = require('soda');
var assert = require('assert');
var browser = soda.createClient({
url: 'http://192.168.12.1/', // localhost website
port:5555,
host:'192.168.1.3', //grid ip
browser: 'firefox',
browserTimeout:5
});
var testname = 'Nits' + parseInt(Math.random() * 100000000); //create unique name for new person.
console.log('randome name: ' + testname);
browser
.chain
.session()
.setSpeed(speed)
.setTimeout(20000)
.open('/')
.and(login('dev#dev.com', 'x1212GQtpS'))
.and(killClient(killAtEnd))
.end(function(err){
console.log('done');
if(err){
console.log(err);
}else{
console.log("We're Good");
}
if (closeAtEnd){
browser.testComplete(function() {
console.log('killing browser');
});
}
});
function login(user, pass) {
return function(browser) {
browser
.click('css=a#loginButton')
.type('css=input.input-medium.email',user)
.type('css=input.input.pwd',pass)
.clickAndWait('css=a.btn.login')
.assertTextPresent('Clients',function(){ console.log('logged in ok')})
}
}
Can you be more specific about exactly where the script stops, fails, or throws an error? I suspect that IE can't handle the way you put your css selector together (i.e. the classname combinators such as 'input.input.pwd' ). I would recommend trying a different selector or rewrite/simplify your existing selector until you get it working.
I'm working on a simple S3 uploader, got it to perform and do what I need to do; however, I was wondering if there was an easy to create an upload progress bar?
At the bottom of the browser, there is a browser message that says "Uploading" - is there any articles anyone knows about that piggy-backs off of this to display a loading bar?
Ideally, that variable will be passed to a jquery function that renders the percentage in the bootstrap progressbar (which accepts integers).
The goal here is to be more aesthetically pleasing, not necessarily 100% accurate.
if you're using a XMLHttpRequest object, you can use onprogress event and the lenghtcomputable attr of the event
.You should only do this if your XMLHttpRequest supports progress
(test = "upload" in new XMLHttpRequest)
var xhr = new XMLHttpRequest();
xhr.open('POST', 'post/picture');
xhr.onload = function() {
progress.value = progress.innerHTML = 100;
};
xhr.upload.onprogress = function (event) {
if (event.lengthComputable) {
var complete = (event.loaded / event.total * 100 | 0);
progress.value = progress.innerHTML = complete;
}
}
xhr.send(formData);
Have you tried the progress bar of jquery UI?
Main of jQuery Progress Bar
I have a struts application, and I am trying to call the Action class with an URL. When I try to pass the request parameters, none of them get appended.
Here is the code I have :
document.myform.action = "mydetails_${firmID}_${empID}.action?id=56";
document.myform.submit();
But this is what I see in chrome console :
mydetails_123_04.action?
For some resaon, the stuff after the question mark is not appended. Am I missing something ?
Don't think you can set params like that in the action. You need to add them as parameters in the form, which involves creating a hidden input node:
var input = document.createElement( 'input' );
input.type = 'hidden';
input.name = 'id';
input.value = 56;
document.forms.myform.appendChild( input );​
My Problem: I write an automated system that needs to read .doc and .odt, performs some operation on it and exports it to pdf again.
Currently that works fine for everything I need, I could solve all problems until this one:
If a user provides a Document that had recorded changes (Redlines) I need to automatically accept all that changes or hide them.
I could solve that one with the code below as long as the OOo is showing on screen. When I launch it hidden, my calls do nothing at all.
So, here is what I do currently:
// DO NOT try to cast this to Desktop as com.sun.star.frame.Desktop is NOT a valid class!
// keep it as Object and cast it to XDesktop later (via queryInterface)
Object desktop = xMCF.createInstanceWithContext("com.sun.star.frame.Desktop", xContext);
XMultiServiceFactory xFactory = (XMultiServiceFactory) UnoRuntime.queryInterface(
XMultiServiceFactory.class, xMCF);
// what goes for desktop above is valid for DispatchHelper as well.
Object dispatchHelper = xFactory.createInstance("com.sun.star.frame.DispatchHelper");
// the DispatchHelper is the class that handles the interaction with dialogs.
XDispatchHelper helper = (XDispatchHelper) UnoRuntime.queryInterface(
XDispatchHelper.class, dispatchHelper);
XDesktop xDesktop = (XDesktop) UnoRuntime.queryInterface(com.sun.star.frame.XDesktop.class, desktop);
XFrame xFrame = xDesktop.getCurrentFrame();
XDispatchProvider xDispatchProvider = (XDispatchProvider) UnoRuntime.queryInterface(XDispatchProvider.class, xFrame);
// We issute the Track Changes Dialog (Bearbeiten - Ă„nderungen // Edit - Changes) and tell it
// to ACCEPT all changes.
PropertyValue[] acceptChanges = new PropertyValue[1];
acceptChanges[0] = new PropertyValue();
acceptChanges[0].Name = "AcceptTrackedChanges";
acceptChanges[0].Value = Boolean.TRUE;
helper.executeDispatch(xDispatchProvider, ".uno:AcceptTrackedChanges", "", 0, acceptChanges);
// We issue it again to tell it to stop showing changes.
PropertyValue[] showChanges = new PropertyValue[1];
showChanges[0] = new PropertyValue();
showChanges[0].Name = "ShowTrackedChanges";
showChanges[0].Value = Boolean.FALSE;
helper.executeDispatch(xDispatchProvider, ".uno:ShowTrackedChanges", "", 0, showChanges);
My current guess is that I cannot call this because being hidden, I have no Frame to call any dispatcher to. But I could not find a way to get the Dispatcher for the Component.
I already tried to dispatch TrackChanges as well (to FALSE) but that didn't do it either.
After spending two days understanding the OOo API, I realized that the document isn't loaded in the frontend which is why this approach fails. However, you can modify the document's property directly:
XPropertySet docProperties = UnoRuntime.queryInterface(XPropertySet.class, document);
docProperties.setPropertyValue("RedlineDisplayType", RedlineDisplayType.NONE);
The property name "RedlineDisplayType" can be found in the RedlinePortion documentation