Adobe AIR NativeProcess Hello World - air

I have
<supportedProfiles>extendedDesktop</supportedProfiles>
in my Application.xml file, but the following is producing this error:
Error #1034: Type Coercion failed: cannot convert flash.filesystem::File#619de81 to flash.desktop.NativeProcessStartupInfo.
<html>
<head>
<title>New Adobe AIR Project</title>
<script type="text/javascript" src="lib/air/AIRAliases.js"></script>
<script type="text/javascript" src="lib/air/AIRIntrospector.js"></script>
<script type="text/javascript" src="lib/jquery/jquery-1.4.2.js"></script>
<script>
function Init(){
var myAIRFile = new air.File('C:/Program Files (x86)/Windows NT/Accessories/Wordpad.exe');
var myProcess = new air.NativeProcess();
var myStartup = new air.NativeProcessStartupInfo();
myStartup.executable = myAIRFile;
myProcess.start(myAIRFile);
}
</script>
</head>
<body onload="Init();">
</body>
</html>

Just use myStartup where it belongs:
myProcess.start(myStartup);

The code looks like an HTML code, which means that you are creating a webapp.
The nativeprocesses, are for applications on the desktop only.
Not for webappications.
Thanks
,
Neeraj

Related

Cloudinary uploader not working with large videos

I'm generating an input tag with Java to upload videos directly from the browser, with the Cloudinary API, which works fine with small videos, but it doesn't work with a 50 MB one.
This is the code generating the input tag:
String html = cloudinary.uploader().imageUploadTag("file", options, htmlOptions);
Map options = ObjectUtils.asMap("resource_type", "video");
options.put("callback", "/cloudinary_cors.html");
options.put("eager", eager);
options.put("eager_async", true);
options.put("tags", videoTags);
options.put("use_filename", true);
Map htmlOptions = ObjectUtils.asMap();
htmlOptions.put("id", "videoInput");
htmlOptions.put("class", "upload");
That's an example of the input tag generated:
<input type="file" name="file"
data-url="https://api.cloudinary.com/v1_1/rentalwebs/video/upload"
data-form-data="{"eager":"c_scale,h_720,w_1280","signature":"xxxfb0c461dxxx",
"api_key":"xxx1647231xxx","eager_async":true,
"callback":"/cloudinary_cors.html","tags":"Demo Website,1,Villa Demo 2",
"use_filename":true,"timestamp":"1548357724"}"
data-cloudinary-field="file" class="cloudinary-fileupload upload" id="videoInput">
And finally, those are the .js scripts attached to the page with the input tag:
<script th:src="#{/js/jquery.ui.widget.js}" type='text/javascript'></script>
<script th:src="#{/js/load-image.all.min.js}" type='text/javascript'></script>
<script th:src="#{/js/canvas-to-blob.min.js}" type='text/javascript'></script>
<script th:src="#{/js/jquery.iframe-transport.js}" type='text/javascript'></script>
<script th:src="#{/js/jquery.fileupload.js}" type='text/javascript'></script>
<script th:src="#{/js/jquery.fileupload-process.js}" type='text/javascript'></script>
<script th:src="#{/js/jquery.fileupload-image.js}" type='text/javascript'></script>
<script th:src="#{/js/jquery.fileupload-validate.js}" type='text/javascript'></script>
<script th:src="#{/js/jquery.cloudinary.js}" type='text/javascript'></script>
$(document).ready(function() {
if($.fn.cloudinary_fileupload !== undefined) {
$("input.cloudinary-fileupload[type=file]").cloudinary_fileupload();
}
});
I may be missing something, which I've been unable to find. There is some more code, dealing with the uploading process and the result, but I guess the problem occurs before, among the code I have attached at this question.
It looks like you just need to add the parameter chunk_size to your options map in Java. This should pass the chunk_size to blueimp which the javascript cloudinary_fileupload is built on.
I would add a chunk size of 20 MB, e.g. options.put("chunk_size", 20000000);

Regarding include js or cs file in view ASP.Net MVC

1) the below code i could write in my view to download any js or cs file at client side
<script type="text/javascript" src="~/Scripts/myScriptFile.js"></script>
OR
#Scripts.Render("~/Scripts/myScriptFile.js")
OR
<script type="text/javascript" src="#Url.Content("~/Scripts/myScriptFile.js")"></script>
then why we need to write my js code inside script section like below one?
#section Scripts{
<script type="text/javascript">
$(function () {
$("#submit1").click(function () {
alert("button");
});
});
</script>
}
2) what is the difference between the below two way to include js/css file in view ?
#Scripts.Render("~/Scripts/myScriptFile.js")
OR
<script type="text/javascript" src="#Url.Content("~/Scripts/myScriptFile.js")"></script>
Each approach will get you the same end result. In my experience, I find the approach to be more flexible and scalable as far as code maintenance goes. I'm not a fan of rendering HTML code through helpers for this reason. I hope this helps.

Declaring Variables in DOJO

I am writing a JSP that displays a list of clubs in a grid. The grid shows the name of the club together with its latitude, longitude, website and description.
The actual data to be displayed is stored in a variable (a dojo.data.ItemFileWriteStore) called clubStore.
When the page is loaded, a call is made to a servlet to retrieve the data. The handling function then deletes all the items held in the store and adds new items returned by the servlet.
The JSP code is shown below:
<%# page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Clubs</title>
<style type="text/css">
#import "./dojoroot/dojo/resources/dojo.css";
#import "./dojoroot/dijit/themes/tundra/tundra.css";
#import "./dojoroot/dojox/grid/resources/Grid.css";
#import "./dojoroot/dojox/grid/resources/nihiloGrid.css";
</style>
<script type="text/javascript" src="dojoroot/dojo/dojo.js"
djConfig="parseOnLoad: true, isDebug: false">
</script>
<script language="JavaScript" type="text/javascript">
dojo.require("dojo.parser");
dojo.require("dojo.data.ItemFileWriteStore");
var clubData={
items:[{name:'No Clubs', lat:'---', lon:'---', webSite:'---', description:'---'}]
};
var layoutClub=[{field:"name", name:"Name", width:10},
{field:"lat", name:"Lat", width:5},
{field:"lon", name:"Long", width:5},
{field:"webSite", name:"Web Site", width:10},
{field:"description", name:"Description", width:'auto'}];
var clubStore=new dojo.data.ItemFileWriteStore(data:clubData});
</script>
<link rel="stylesheet" href="dojoroot/dijit/themes/claro/claro.css" />
<link rel="stylesheet" href="dojoroot/dojox/widget/Dialog/Dialog.css" />
</head>
<body class="tundra">
<%#include file="header.jsp"%>
<div id="clubGrid"
style="width: 800px;"
autoHeight="true"
data-dojo-type="dojox/grid/DataGrid"
data-dojo-props="store:clubStore,
structure:layoutClub,
query:{},
queryOptions:{'deep':true},
rowsPerPage:40">
</div>
<br>
<script>
var urlString="http://localhost:8080/BasicWeb/ClubsServlet";
dojo.xhrGet({
url: urlString,
handleAs: "text",
load: function(data) {
// remove items...
var allData=clubStore._arrayOfAllItems;
for (i=0; i<allData.length; i++) {
if (allData[i]!=null) {
clubStore.deleteItem(allData[i]);
}
}
var jsonClubArray=JSON.parse(data);
for (var i=0; i<jsonClubArray.clubs.length; i++) {
var club=jsonClubArray.clubs[i];
var newClub={name: club.clubname, lat:club.lat, lon:club.lon, webSite: club.website, description: club.description};
clubStore.newItem(newClub);
}
clubStore.save();
}
});
</script>
</body>
</html>
The script to process the servlet response sometimes fails because clubStore is undefined (debugging using Firebug). This does seem to be a spurious fault as some times everything works perfectly.
Any assistance in understanding how to define the clubStore variable would be appreciated.
Thanks.
James.
I think what might be happening is the body script is sometimes running before the head script, so it is kind of a race condition. You could try wrapping your body script into a dojo.ready. (I assume from your code that you are using dojo 1.6 or earlier since you are not using the AMD loader style.)
dojo.ready(function(){
// Put your xhr request code here.
});
You may also want to try testing with a firebug breakpoint in the head and body script. See if the head is sometimes running first.
So the problem turned out to be a syntax error in the declaration - missing '{' in the line
var clubStore=new dojo.data.ItemFileWriteStore(data:clubData});
The spurious aspect to the fault was a red herring - I had previously declared the variable as part of the DOM object and that caused a spurious fault. So I messed up my regression testing as well as introducing a syntax error!
Thanks.
James.
You could try switching the order of your require statements, so it's like this:
dojo.require("dojo.data.ItemFileWriteStore");
dojo.require("dojo.parser");
If that fails, you could set parseOnLoad to false, and then call dojo.parser.parse() after your store has been instantiated like so:
(assuming you are using dojo 1.6 or earlier based on your code)
dojo.addOnLoad(function() {
dojo.parser.parse();
});
Put your clubStore in the global space... just remove the var keyword in front of it...

Coding with Dojo, received error 'dijit.byId(...)' is null or not an object

I see many references to this error on the web, but they are not helping me. I guess i am new enough to this that i need a specific answer for my problem.
I am attaching the first portion of code on a page that i am running. the last line i show is the line that is creating the error stating in the title. Please let me know if you have any suggestions.
Thank you!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>CDI Web Portal</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<script src="js\dojo\dojo.js" type="text/javascript"></script>
<script type="text/javascript" src="http://www.google.com/jsapi?key=ABQIAAAA5a4NhilcmrdMQ5e3o22QWRQWrGbhbxAguaJ-a4SLWYiya7Z2NRTDfQBdxmHdf5ydkZYLZTiz1tDXfg"></script>
<script type="text/javascript" src="ge-poly-fit-hack.js"></script>
<script type="text/javascript" src="kmldomwalk.js"></script>
<style type="text/css">
#import "js/dijit/themes/tundra/tundra.css";
#import "js/dojo/resources/dojo.css";
</style>
<style type="text/css">#import "index.css";</style>
<script type="text/javascript"> dojo.ready(function() { dojo.byId("greeting").innerHTML += ", from " + dojo.version; }); </script>
<script type="text/javascript">
// <![CDATA[
djConfig = { parseOnLoad: true };
// google.load("dojo", "1.6.1");
google.load("maps", "2");
google.load("earth", "1");
var g_ge;
var g_earthDisabled = false;
var g_kmlObject;
google.setOnLoadCallback(function() {
dojo.require('dijit.layout.BorderContainer');
dojo.require('dijit.layout.SplitContainer');
dojo.require('dijit.layout.ContentPane');
dojo.require('dijit.Tree');
//dojo.require('CheckboxTree');
dojo.require('dijit.form.CheckBox');
dojo.require('dijit.form.Button');
dojo.require('dijit.form.TextBox');
dojo.require('dojo.data.ItemFileWriteStore');
dojo.require('dojo.parser');
dojo.require('dojo.cookie');
dojo.require('dojo.fx');
dojo.addOnLoad(function() {
// load checkboxtree
var scpt = document.createElement('script');
scpt.src = "dijit.CheckboxTree.js";
document.body.appendChild(scpt);
{ dijit.byId('load-button').setDisabled(true) };
// build earth
google.earth.createInstance(
'map3d',
function(ge) {
g_ge = ge;
g_ge.getWindow().setVisibility(true);
g_ge.getNavigationControl().setVisibility(ge.VISIBILITY_AUTO);
g_ge.getLayerRoot().enableLayerById(g_ge.LAYER_BORDERS, true);
g_ge.getLayerRoot().enableLayerById(g_ge.LAYER_BUILDINGS, true);
dijit.byId('load-button').setDisabled(false);
checkAutoload();
},
function() {
g_earthDisabled = true;
dijit.byId('load-button').setDisabled(true);
From your comment, you used declarative syntax to create the dijit, i.e. <button id="load-button" dojoType="dijit.form.Button" onclick="loadKml();">. If the declarative syntax is used, the dijit is actually created after the page is loaded. So you should put the code to use the dijit in the Dojo's load callback, i.e. inside of dojo.addOnLoad callback.
But your code is bad formatted and mingled with Google Maps load callback, it's not easy to inspect the code. My suggestion would be to wrap the dijit.byId('load-button').setDisabled(true); with dojo.addOnLoad, like below:
dojo.addOnLoad(function() {
dijit.byId('load-button').setDisabled(true);
});
It means that you've got a dojo object rather than a dijit object -- or possibly no object named load-button at all, since it's not clear from this where load-button is being created. Make sure there is an object with id="load-button" that was created with dijit.

Google transliterate API problem in Firefox

I am trying to use Google Transliterate API helloWorld in Firefox 4.0.1 and WindowsXP
I am using node.js 0.4.7 to serve the page
When I load the page through node.js, i get the following error: "attempt to run compile-and-go script on a cleared scope"
The page is rendered successfully if I double-click it and open in Firefox from disk, or if I open it in IE8, Opera or Chrome
Any idea why this happens and what is the way around it? Here is the code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<script type="text/javascript" src="https://www.google.com/jsapi?api-key-here">
</script>
<script type="text/javascript">
// Load the Google Transliterate API
google.load("elements", "1", {
packages: "transliteration"
});
function onLoad() {
var options = {
sourceLanguage:
google.elements.transliteration.LanguageCode.ENGLISH,
destinationLanguage:
[google.elements.transliteration.LanguageCode.URDU],
shortcutKey: 'ctrl+g',
transliterationEnabled: true
};
// Create an instance on TransliterationControl with the required
// options.
var control =
new google.elements.transliteration.TransliterationControl(options);
// Enable transliteration in the textbox with id
// 'transliterateTextarea'.
control.makeTransliteratable(['transliterateTextarea']);
}
google.setOnLoadCallback(onLoad);
</script>
</head>
<body>
Type in Urdu (Press Ctrl+g to toggle between English and Urdu)<br>
<textarea id="transliterateTextarea" style="width:600px;height:200px"></textarea>
</body>
</html>