i get a typeerror when executing the below in my ant deploy.xml file, any idea what's wrong?
This worked about two weeks ago
command:ant -f deploy.xml
ant version: 1.9.4
error:javax.script.ScriptException: TypeError: Cannot load script from Packages.org.apache.tools.ant.types.ZipFileSet
<script language="javascript"><![CDATA[
var version = java.lang.System.getProperty("java.version");
if ( version.startsWith("1.8.0")) {
load(Packages.org.apache.tools.ant.types.ZipFileSet);
load(Packages.org.apache.tools.ant.taskdefs.Zip);
} else {
importClass(Packages.org.apache.tools.ant.types.ZipFileSet);
importClass(Packages.org.apache.tools.ant.taskdefs.Zip);
}
]]>
</script>
using the suggestion below fixed the error.
i.e.
var Zip = org.apache.tools.ant.taskdefs.Zip;
Java 8 Javascript Engine backwards compatibility
Related
I am developing the mobile application using Oracle MAF. In that application I need to implement the Signature capture functionality.
For that I have downloaded the Signature Capture Demo app from this link.
And trying to integrate with my application. I did all the necessary settings mentioned in that link.
But after running the application I am getting following error
TypeError: Object[object Object] has no method 'signature'
The Piece of code as follows
<![CDATA[
<script type="text/javascript">
(function()
{
makeSig = function() {
try
{
var sigElement = document.getElementById("sig");
if (sigElement == null)
alert("sigElement not found");
var sigJq = $(sigElement);
sigJq.signature();
sigJq.signature({guideline: true});
}
catch (problem)
{
alert("Problem with verbatim code: " + problem);
}
}
window.setTimeout(makeSig, 250);
})();
</script>
<div id="sig" style="height:200px;width:99%"></div>
]]>
Please let me know why it is not able to find the signature method. I have also included all the required .js files in the project.
Thanks in Advance.
Make sure you are properly including the library:
<script type="text/javascript" src="js/jquery.signature.js"></script>
then try something like this
var sigJq = $("sig");
sigJq.signature();
Trying to use PDF JS in a local Apache server and receiving the following error in console:
Uncaught Error: No PDFJS.workerSrc specified
This is very weird, because I'm following all that the examples specifies here http://mozilla.github.io/pdf.js/examples/.
I have, in my main folder, a sample file called file.pdf and I'm just trying to display it. I did it by using a iframe with a file parameter:
<iframe src="./web/viewer.html?file=http://localhost:99/PDF/arquivo.pdf" width="1800px" height="900px" />
And now I'm trying to use the JavaScript API to display it. I'm trying to do:
<!DOCTYPE html>
<html>
<head>
<script src="./build/pdf.js" type="text/javascript"></script>
<script type="text/javascript">
PDFJS.getDocument('arquivo.pdf').then(function(pdf) {
// Here I use it
})
</script>
</head>
<body>
</body>
</html>
If I try to include pdf.worker.js manually, I receive:
GET http://localhost:99/PDF/build/pdf.worker.worker.js 404 (Not Found)
because it programmatically includes pdf.worker.js.
With the sample code I posted here, I receive a log and an error:
Error: No PDFJS.workerSrc specified pdf.js:249
at error (http://localhost:99/PDF/build/pdf.js:251:15)
at Object.WorkerTransport (http://localhost:99/PDF/build/pdf.js:2305:9)
at Object.getDocument (http://localhost:99/PDF/build/pdf.js:1805:15)
at http://localhost:99/PDF/:6:10 pdf.js:251
Warning: Unsupported feature "unknown" pdf.js:234
Uncaught Error: No PDFJS.workerSrc specified
Do I need to manually specify pdf.worker.js?
Please, what can I try to solve this?
Thank you so much!
(*) - I can see a lack of good content and a well explained documentation of PDF.JS.
I had a similar error and I fixed it by specifying the pdf.worker.js explicitly at the end of the pdf.js
if (!PDFJS.workerSrc && typeof document !== 'undefined') {
// workerSrc is not set -- using last script url to define default location
****** I have no clue what the code below hope to accomplish ********
****** How can it locate the script container by assuming it ********
****** always would be at the end of <body> or <head> ???? ********
PDFJS.workerSrc = (function () {
'use strict';
var scriptTagContainer = document.body ||
document.getElementsByTagName('head')[0];
var pdfjsSrc = scriptTagContainer.lastChild.src;
return pdfjsSrc && pdfjsSrc.replace(/\.js$/i, '.worker.js');
})();
****** Here I just hardcode the location of the needed file *********
****** This is the part that makes it work. *********
****** Obviously, tailor this to the same path of pdf.js *********
PDFJS.workerSrc = '/static/js/pdf.worker.js';
}
Include compatibility.js to fix the "Uncaught Error: No PDFJS.workerSrc specified" error on IE11.
https://github.com/mozilla/pdf.js/blob/master/src/shared/compatibility.js
<script src="compatibility.js"></script>
<script src="pdf.js"></script>
compatibility.js implements any missing functionality required by PDFJS.
Note: It should be loaded before PDFJS, not after.
Specify psd.worker.js file path in your page where you want to use the pdf.js file (viewer.html in case you are using viewer.html come with distribution bundle) like this. It work for me.
<script>
PDFJS.workerSrc ='path to psd.worker.js';
I added below code in end of pdf.js and working fine
if (!PDFJS.workerSrc && typeof document !== 'undefined') {
PDFJS.workerSrc = (function () {
'use strict';
var scriptTagContainer = document.body ||
document.getElementsByTagName('head')[0];
var pdfjsSrc = scriptTagContainer.lastChild.src;
return pdfjsSrc && pdfjsSrc.replace(/\.js$/i, '.worker.js');
})();
PDFJS.workerSrc = 'pdf.worker.js';
}
Go to pdf.js
search function getWorkerSrc()
replace this lines
pdfjsFilePath = "YOUR_PATH_TO_JS_FILE/pdf.worker.js";
if (pdfjsFilePath) {
return pdfjsFilePath;
}
Please can you help -- why does this JSON not work
the head of my page looks like this
<script src="Scripts/json2.js" type="text/javascript"></script>
<script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script src="Scripts/JScript.js" type="text/javascript"></script>
and my ajax looks like this
var p = { "myText": JSON.stringify(tableOBJ) };
$.ajax({
type: "POST",
url: "Default2AJAX.aspx",
data: p,
success: function (data) {
var obj = JSON.parse(data);
}
});
In firefox I get this error on the JSON
Error: syntax error
Source File: /Scripts/json2.js
Line: 4
Source Code:
<!DOCTYPE html>
In IE 7 I get JSON undefined
in ie 8 i get
SCRIPT1002: Syntax error json2.js, line 4 character 1
In ie 9 i get
SCRIPT1002: Syntax error json2.js, line 4 character 1
How do I fix this? as I have added json2.js but it appear if the browser doesnt need it it throws an error?
Change Scripts/json2.js to point to a real copy of json2.js. At the moment it is pointing to an HTML document (probably a 404 error page).
I am betting that the file "Scripts/JScript.js" does not exist on your server and that the Source Code: <!DOCTYPE html> is a 404 error page.
#Hello-Word & #Rocket Hazmat:
The file at github link is an html file. To solve the problem:
Download json2.js
Change the file extension to html
Open the file in a web browser
Scroll down the page, copy the javascript code portion, and save it to a new file as json2.js
BTW, thanks to Douglas for the json parser. Makes my life much easier.
There appears to be an error in the json2.js file you are using -- at least IE 8 & 9 agree that an error exists on line 4 of that file.
I'm using HTA and in it I have a function that should run a command line with wshell.run , If I'm writing this line in Windows 'Run' util it is working fine, I want it to work also in the HTA with wshell.run.
The line is:
C:\xxxx\xxx\xxx.EXE aaa.psl abc
( The names are xxx just in here - not in the real code.. )
In the javascript code I'm using:
function runCmd()
{
wshShell.exec( "C:\xxxx\xxx\xxx.EXE aaa.psl abc" );
}
The error I got is in the xxx.EXE application says "couldn't open aaa.psl File not found".
Thanks,
Rotem
I'm surprised the xxx.EXE program is running at all. You need to escape those backslashes in the command:
wshShell.Exec( "C:\\xxxx\\xxx\\xxx.EXE aaa.psl abc" );
// ^-----^----^--- here
If you're doing the same thing in the aaa.psl filename, that's your problem.
If you're not passing a full path to the aaa.psl file, then most programs (not all) will expect it to be in the current directory, so you'll want to make sure you've set the current directory correctly (although using absolute paths may be a better option).
Here's an example, for instance, of telling Notepad to edit a file:
shell = WScript.CreateObject("WScript.Shell");
shell.Exec("c:\\windows\\system32\\notepad.exe c:\\temp\\temp.txt");
...or via the current directory:
shell = WScript.CreateObject("WScript.Shell");
shell.CurrentDirectory = "c:\\temp";
shell.Exec("c:\\windows\\system32\\notepad.exe temp.txt");
Okkkk T.J. is the man!! :)
I finnaly made it with your help by replacing exec to run:
This is the final (and working) code:
function runCmd()
{
wshShell.CurrentDirectory = "G:\\xxx\\xxx";
wshShell.run( "xxx.EXE xxx.psl abc" );
}
I ran into a problem using QWebChannel for accessing an object from JavaScript. I'm currently using Qt5.4.2.
Here's my CPP code :
myObject::myObject(QWidget *parent)
: QMainWindow(parent)
{
QWebEngineView* m_pView = new QWebEngineView(this);
QWebChannel channel;
channel.registerObject(QString("myObject"), this);
m_pView->load(QUrl("file:///D:/index.html"));
setCentralWidget(m_pView);
}
In my index.html, I am including qwebchannel.js :
<script type="text/javascript" src="qrc:///qtwebchannel/qwebchannel.js"></script>
And in my javascript file, I am trying to retrieve my object like this :
new QWebChannel(qt.webChannelTransport, function(channel) {
var myObject = channel.objects.myObject;
});
However, I get the following error in the console :
Error: qt is not defined
I also tried to replace it with navigator.qtWebChannelTransport but I got :
Error: transport is not defined
Can somebody tell me what did I do wrong? Thanks.
Edit : Is qt.webChannelTransport only accessible with Qt5.5? It seems to be the case when I read the doc of QWebEnginePage::setWebChannel...
You must setWebChannel before load url
Thats correct.
QWebChannel integration with QWebEngine is only available from version 5.5 as stated here by Milian, the main developer of the module.
You have to google qwebchannel.js to get the default code (it's a lot of code actually) or get it from out of Qt's directories somehow. I put mine under <qrc>/qtwebchannel/qwebchannel.js. Then make sure you import it as a regular javascript into your index.html but with source as "qrc:/qtwebchannel/qwebchannel.js". I had your exact error earlier today, and something I did fixed it - was probably including that script.
For others having the same issue but using Qt 5.5+, make sure you have QT += webchannel in your .pro file.