function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ivaylo BalabanovIvaylo 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

Vamsi KrishnaVamsi Krishna
can you share your current code and we can suggest where its failing..
Ivaylo BalabanovIvaylo Balabanov
That is the file index.jsp

 <%@ 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
Nidhi ShekarNidhi Shekar
I am having  the same issue as well. 
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 
Nidhi ShekarNidhi Shekar
Hi I finally got this issue resolved. There was a problem with the sdk folder in the Canvas SDK. Although you clone the repository to your Git, the sdk folder still points to the original canvas SDK project. So I put the SDK folder in the parent directory and reference canvas-all.js and all other files in the sdk to point to the new sdk folder i created.
Rajagopal AkellaRajagopal Akella
I am not sure what @Nidhi Shekar had done, as I am not able to understand / replicate the fix. But the fix that i followed was, just a couple of pages ahead in the document (starting of Chapter 4), there is a statement mentioned to replace:
<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