Create a flash object in CQ 5.6.1 - aem

I am implementing amcharts in CQ. I get the data by calling a servlet which I temporarily hosted in a local glassfish server. Following is the code snippet of my amchart component jsp.
<%#include file="/libs/foundation/global.jsp"%><%
%><%#page session="false" %><%
%><html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Test amcharts generation</title>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<div id="container">
<div id="singlesection" class="norm" >
<div class="norm">
<script type="text/javascript" src="/apps/geometrixx/components/amchart/am/swfobject.js"></script>
<div id="flashcontent"><strong>You need to upgrade your Flash Player</strong></div>
<div id="result"></div>
<script type="text/javascript">
// <![CDATA[
var so = new SWFObject("/apps/geometrixx/components/amchart/am/amstock.swf", "amstock", "600", "400", "8", "#FFFFFF");
var uri = "http://localhost:8080/Charts/apps/CreateXMLFileServlet?r="+Math.random()+"&fc=03";
so.addVariable("settings_file", encodeURIComponent(uri));
so.addVariable("chart_id", "amstock");
so.addVariable("key", "106-d0564444fe0a5ce6839d84f70655375c");
so.write("flashcontent");
// ]]>
</script>
</div>
</div>
</div>
</body>
The issue is, the servlet is not getting called. If I try the servlet url directly from the browser, I get the response. Please suggest what I am doing wrong here. Thank you.

It sounds like you may be running into a cross-domain security restriction. If you are loading the page the has the SWF code from one domain, but then calling a different domain to get the data, you are likely running into security restrictions. Can you list the full domains for both pieces?
Check out http://www.adobe.com/devnet/articles/crossdomain_policy_file_spec.html for info on how to get around this.

Related

Error: Target container is not a DOM element (when running Purescript Pux Program)

I've compiled this program with Purescript 0.12.5 but when I look at the index.html in Firefox 67.0.2 I get the following error in the web console:
Error: Target container is not a DOM element. app.js:5160:15
Here is the index.html file:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<title>PS3</title>
<script src="https://unpkg.com/react#16/umd/react.production.min.js"
crossorigin></script>
<script src="https://unpkg.com/react-dom#16/umd/react-
dom.production.min.js" crossorigin></script>
<script src='app.js'></script>
</head>
<body>
<div id="app"></div>
</body>
</html>
Any help would be appreciated!
This is because you're loading the program before the <div id="app"> element, so the element doesn't yet exist at the time the program is running and trying to find it.
Try moving the <script> tag after the <div>:
<html>
<head>
...
</head>
<body>
<div id="app"></div>
<script src='app.js'></script>
</body>
</html>

How to, with outlook client, perform reply with a HTML button?

I'm developing one WPF application with email integration.
The emails generated by application are simply HTML pages like that:
<!DOCTYPE html>
<html>
<head>
<title>My Title</title>
<meta charset="utf-8" />
<style type="text/css">
</style>
</head>
<body>
<div>
<div class="actions">
Approve
Reject
</div>
</div>
</body>
</html>
I need to know how to create one HTML button that can perform automatically reply with outlook.
Can you help me?
Thanks
HTML in Outlook is rendered by Word, not IE. Your HTML scripts and buttons will not run inside Outlook.
<!DOCTYPE html>
<html>
<head>
<title>My Title</title>
<meta charset="utf-8" />
<style type="text/css">
</style>
</head>
<body>
<div>
<div class="actions">
<button onclick="location.href='mailto:myemail#mail.com?subject=Approve'">Approve</button>
<button onclick="location.href='mailto:myemail#mail.com?subject=Reject'">Reject</button>
</div>
</div>
</body>
</html>

Minimum includes for Alfresco Share custom page?

I am creating a custom Share page that must have none of the Alfresco UI on it, but which still needs access to the Alfresco and YAHOO objects.
I have successfully created the page and caused it to open in a new tab, but I get errors that the Alfresco and YAHOO objects are undefined.
What are the minimum includes I must add to my Freemarker template to get access to those objects?
Update: I have gotten the Alfresco and YAHOO objects to load, but now am getting "Uncaught Error: extend failed, please check that all dependencies are included."
Here are the freemarker and javascript includes I've got so far, if it'll help:
<#import "import/alfresco-common.ftl" as common />
...
<script type="text/javascript" src="../scripts/ajax/yahoo/yahoo-min.js"> </script>
<script type="text/javascript" src="../scripts/ajax/yahoo/connection/connection-min.js"> </script>
<script type="text/javascript" src="../scripts/ajax/common.js"> </script>
<script type="text/javascript" src="../scripts/ajax/utilities/utilities.js"> </script>
<script type="text/javascript" src="../yui/yuiloader/yuiloader.js"> </script>
<script type="text/javascript" src="../js/alfresco.js"> </script>
Update 2: Based on the first answer, the first few lines of the template look like this and again yield Uncaught ReferenceError: YAHOO is not defined:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<region-id>head-resources</region-id>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<title></title>
<script>
var urlParams;
Update 3: I've reduced the source to the minimum necessary to demonstrate the problem. What follows next is the template component definition file, followed by the freemarker template itself. Definition:
<?xml version='1.0' encoding='UTF-8'?>
<page>
<title>iPad Viewer</title>
<title-id>page.iPad.title</title-id>
<description>iPad Viewer</description>
<description-id>page.iPad.description</description-id>
<template-instance>viewer-ipad</template-instance>
<authentication>user</authentication>
</page>
Freemarker template:
<html>
<body>
<div class="content">
<#region-id>head-resources</#region-id>
<script>
alert(YAHOO);
alert(Alfresco);
</script>
</div>
</body>
</html>
Error is:
Caused by: freemarker.core.ParseException: Parsing error in template "org/alfresco/viewer-ipad.ftl" in line 11, column 7: Unclosed #... when the end of the file was reached.
I'm not sure how you created the page, but this is not needed when you define your regions.
Probably there are all in the <region-id>head-resources</region-id> So if you include that in the page-template that should suffice.

How to load dojo into html file in order to call dojox.mobile functions?

Ok so I'm fairly new to dojo and I'm trying to make a really simple sample mobile app. I'm using eclipse to run the code which uses an android emulator to install/run the app. The problem I'm having is that I keep getting Uncaught Reference Errors for either "require is not defined" or "dojo is not defined", causing my app to appear as plain text instead of formatted like an android app using dojox.mobile widgets.
Here is my code:
<!DOCTYPE HTML>
<html>
<head>
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,
minimum-scale=1,user-scalable=no"/>
<title>PhoneGap</title>
<!-- DOJO -->
<script src="/assets/www/lib/dojo/dojo/dojo.js" data-dojo-config="isDebug: true, parseOnLoad:true">
</script>
<link rel="stylesheet" href="/assets/www/lib/dojo/dojox/mobile/themes/android/android.css"
type="text/css" media="screen" title="no title" charset="utf-8">
<script type="text/javascript" charset="utf-8" src="/assets/www/cordova-1.6.0.js"></script>
<script>
require(["dojo"], function(dojo) {
dojo.require("dojox/mobile")
dojo.require("dojox/mobile/parser")
});
</script>
</head>
<!-- END DOJO -->
<body>
<!-- ACCIDENT TOOLKIT PAGE -->
<div data-dojo-type="dojox.mobile.View" id="accHelp" selected="true">
<h1 data-dojo-type="dojox.mobile.Heading">Accident</h1>
<div class="text">If you are in an accident, you should first move to a safe
location. Below are some additional actions you can take:</div>
<ul data-dojo-type="dojox.mobile.RoundRectList">
<li data-dojo-type="dojox.mobile.ListItem"
onclick="window.location='geo:0,0?q=police';">Call the Police</li>
<li data-dojo-type="dojox.mobile.ListItem"
onclick="window.location='geo:0,0?q=towing';">Call for a Tow Truck</li>
<li data-dojo-type="dojox.mobile.ListItem" moveTo="accInfo" transition="slide"
onClick="itemClicked();">Exchange Driver Info</li>
<li data-dojo-type="dojox.mobile.ListItem" moveTo="accInfo" transition="slide"
onClick="itemClicked();">Record Accident Location</li>
<li data-dojo-type="dojox.mobile.ListItem" moveTo="accInfo" transition="slide"
onClick="itemClicked();">Take Photos of Accident</li>
</ul>
</div>
<!-- EXCHANGE DRIVER INFO PAGE -->
<div data-dojo-type="dojox.mobile.View" id="accInfo">
<h1 data-dojo-type="dojox.mobile.Heading" back="Accident" moveTo="accHelp"
onClick="console.log('Going back');">Driver</h1>
<h2 data-dojo-type="dojox.mobile.RoundRectCategory">Other Driver Info</h2>
</div>
<script>
function itemClicked() {
console.log("itemClicked()");
}
</script>
</body>
</html>
Does anything appear wrong with the code itself? Especially where I'm using the script scr... to point to the dojo.js and where I'm using require to call the dojo.mobile functions. I was under the impression that as long as the src pointed to the right location in the package tree, it didn't much matter where I copied the file in.
I have tried using the Google CDN to call dojo.js, but the emulator throws errors when I do so, possibly because it doesn't utilize an internet connection?
Any help would be great!
Try removing /assets/www/ from your local URLs
Your require statement looks like this:
require(["dojo"], function(dojo) {
dojo.require("dojox/mobile")
dojo.require("dojox/mobile/parser")
});
And it should look something like this:
require([
"dojo/mobile",
"dojo/mobile/parser"
],
function(mobile, parser) {
// your code here;
});

Javascript SDK connect() function not working in chrome

Am attempting to model my code after the example here: http://connect.soundcloud.com/examples/connecting.html#
It works in firefox, but not in chrome. In chrome, the soundcloud popup shows up correctly, and I can sign in (returning to sc-connect.html), but then the window won't close. Upon closer inspection, there's a javascript error because window.opener is null. I wonder if it has to do with localhost uri? The example at the link above works in both firefox and chrome. Any ideas? My code below:
SC.initialize({client_id:'my_client_id', redirect_uri:'http://localhost:3000/sc-connect.html'});
$('button').click(function(){
SC.connect(function () {
console.log('made it');
}
}
My sc-connect.html page looks like:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Connect with SoundCloud</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<body onload="window.opener.setTimeout(window.opener.SC.connectCallback, 1)">
<b style="width: 100%; text-align: center;">This popup should automatically close in a few seconds</b>
</body>
</html>
Redirect URI on soundcloud for this app: http://localhost:3000/sc-connect.html
This is actually a strange bug in Chrome which is caused by installing the SoundCloud app from the Chrome App Store. Bizarre, I know.
A workaround is instead of using window.opener, push the oauth token into LocalStorage or SessionStorage and have the opener window listen to the Storage event.
It looks like you're missing a couple of closing brackets in your example code. Other than that, nothing appears obviously wrong with your example. I copied and pasted your sc-connect.html and used it with the following:
<html>
<head>
<title>Demo</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script type="text/javascript" src="http://connect.soundcloud.com/sdk.js"></script>
<script type="text/javascript">
$(document).ready(function() {
SC.initialize({
client_id: 'MY_CLIENT_ID',
redirect_uri: 'http://localhost:8080/connect/sc-callback.html'
});
$('button').click(function(){
SC.connect(function() {
SC.get('/me', function(data) {
$('#name').text(data.username);
});
});
});
});
</script>
</head>
<body>
<button>Connect</button>
<p>
Hello There, <span id="name"></span>
</p>
</body>
</html>
This works for me in Firefox and Chrome. Let me know if the that helps.
<!DOCTYPE html> <html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Connect with SoundCloud</title>
</head>
<body onload="window.opener.setTimeout(window.opener.SC.connectCallback, 1)">
<b style="text-align: center;">This popup should automatically close in a few seconds</b>
<script type="text/javascript">window.opener.SC.connectCallback.call(this); </script>
</body>
</html>