You need to sign in to do that
Don't have an account?
Ivaylo Balabanov
Problem with Canvas Hello World application
Hello,
I have implemented the Hello world Canvas application in Sf but for some reason the Hello User.Full name does not swow up.
I can see only Hello.
The Java script does not work. What could be the reason.
I have implemented the other test application
http://www.salesforce.com/us/developer/docs/integration_workbook/integration_workbook.pdf
but still the information does not show up there.
Any ideas?
Regards,
Ivo
I have implemented the Hello world Canvas application in Sf but for some reason the Hello User.Full name does not swow up.
I can see only Hello.
The Java script does not work. What could be the reason.
I have implemented the other test application
http://www.salesforce.com/us/developer/docs/integration_workbook/integration_workbook.pdf
but still the information does not show up there.
Any ideas?
Regards,
Ivo
<%@ page import="canvas.SignedRequest" %>
<%@ page import="java.util.Map" %>
<%
// Pull the signed request out of the request body and verify and decode it.
Map<String, String[]> parameters = request.getParameterMap();
String[] signedRequest = parameters.get("signed_request");
if (signedRequest == null) {%>
This app must be invoked via a signed request!<%
return;
}
String yourConsumerSecret=System.getenv("CANVAS_CONSUMER_SECRET");
String signedRequestJson = SignedRequest.verifyAndDecodeAsJson(signedRequest[0],
yourConsumerSecret);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<title>Hello World Canvas Example</title>
<link rel="stylesheet" type="text/css" href="/sdk/css/connect.css" />
<script type="text/javascript" src="/sdk/js/canvas-all.js"></script>
<!-- Third part libraries, substitute with your own -->
<script type="text/javascript" src="/scripts/json2.js"></script>
<script>
if (self === top) {
// Not in an iFrame.
alert("This canvas app must be included within an iFrame");
}
Sfdc.canvas(function() {
var sr = JSON.parse('<%=signedRequestJson%>');
Sfdc.canvas.byId('username').innerHTML = sr.context.user.fullName;
});
</script>
</head>
<body>
<br/>
<h1>Hello <span id='username'></span></h1>
</body>
</html>
I have followed that instruction http://www.salesforce.com/us/developer/docs/platform_connectpre/canvas_framework.pdf
I tried Sfdc.canvas.byId('username').innerHTML = "Test";
but it does not appear either.
Regards,
Ivo
var a=sr.context.user.fullName;
var b= Sfdc.canvas.byId('username').innerHTML;
in script tags.
Alert(a);
and alert(b);
is both showing empty string
<script type="text/javascript" src="/sdk/js/canvas-all.js"></script>
with:
<script type="text/javascript" src="https://<instance>.salesforce.com/canvas/sdk/js/45.0/canvas-all.js"></script>
in the file:
\src\main\webapp\examples\hello-world\index.jsp
Ensure, you do this modification immediately once you download the git folder, and then follow steps in compiling the program (because, this will ensure target folder, and keystore file are not yet created).
There is one more issue with the document (referring to latest Canvas Developer Guide, as on 15th April 2019): If you are using Java 8, you will not be able to run the application, as you will receive HTTPS 500 Error. The fix you need to follow is, you need to uninstall existing Java program from control pannel>uninstall program., and then install Java 7 from the below link, and ensure your environment vatiables for JAVA_HOME (JDK path), and path (JDK\bin., and JRE\bin) are updated to Java 7 folders in your program files folder.
Download Java SE7 from the below link, and install:
https://www.oracle.com/technetwork/java/javase/archive-139210.html