+ Start a Discussion
Paul BachmannPaul Bachmann 

Getting Token Error on my Controller

Getting this error  [Error] Error: Compile Error: unexpected token: 'ApexPages.StandardController' at line 3 column 37
I'm trying to add the ApexPages so I can add this VF page via page layout editor.

Thanks,  Paul

public with sharing class CapturePSignatureController {

public CapturePSidnature Controller {ApexPages.StandardController} { 
 
 @RemoteAction
 global static String savePSignature(String imageUrl, String accountId) {
 
  
  try {
   Attachment accSign = new Attachment();
   accSign.ParentID = accountId;
   accSign.Body = EncodingUtil.base64Decode(imageUrl);
   accSign.contentType = 'image/png';
   accSign.Name = 'Patient Signature Image';
   accSign.OwnerId = UserInfo.getUserId();
   insert accSign;
   
   return 'success';
   
  }catch(Exception e){
   system.debug('---------- ' + e.getMessage());
   return JSON.serialize(e.getMessage());
  }
  return null; 
 }

}
 
Steven MellerSteven Meller
Paul
Couple of problems with this line:  Sidnature should be Signature, curly brackets should be parentheses around the ApexPages parameter.
public CapturePSidnature Controller {ApexPages.StandardController} { 
Let me know how that works for you.
Steve

 
Paul BachmannPaul Bachmann
Changed the curly brackets in {ApexPages.StandardController} { to paentheses and now getting this error
[Error] Error: Compile Error: unexpected token: ')' at line 3 column 69

Thanks for the quick response
Steven MellerSteven Meller
Paul
This is a parameter declaration right?  So needs a parameter name, not just the type.
Then are you going to use that parameter? Do you need a parameter if you are not using it?
Steve
 
Paul BachmannPaul Bachmann
Well,  here is my situation.  I am an SA with a functional background, so my coding skills are not the greatest.  I'm trying to build an E-Signature component for a client of mine that is a non-profit (so pro-bono with no technical developer).  I need an esignature capability on the Case record that I call up as an image via custom print preview. Then have a hardcopy of that Case record printed out.
I am close to having it work, as I can make it all happen in "preview" mode.  Problem is it's a hodge podge of code I've found and I guess my controller needs some work to enable the VF page to be seen/added via standard page editor in SFDC, hence the ApexPages.StandardController problem I'm having since I realized that is why I was not seeing my VF Page through the page editor.

Here is my current controller
global with sharing class CapturePSignatureController {
 
 
 @RemoteAction
 global static String savePSignature(String imageUrl, String accountId) {
 
  
  try {
   Attachment accSign = new Attachment();
   accSign.ParentID = accountId;
   accSign.Body = EncodingUtil.base64Decode(imageUrl);
   accSign.contentType = 'image/png';
   accSign.Name = 'Patient Signature Image';
   accSign.OwnerId = UserInfo.getUserId();
   insert accSign;
   
   return 'success';
   
  }catch(Exception e){
   system.debug('---------- ' + e.getMessage());
   return JSON.serialize(e.getMessage());
  }
  return null; 
 }

}
Here is my current VF Page Code
 
<apex:page docType="html-5.0" controller="CapturePSignatureController" showheader="false" sidebar="false" standardStylesheets="false" id="pg">
 <apex:includeScript value="/soap/ajax/28.0/connection.js"/>
 
 <style>
  .container {
   text-align: center;
   font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
   color: cadetblue;
   font-weight: 500;
   font-size: 14px;
  }
  
  .button {
   font-family: calibri;
   border-radius: 8px;
   background-color: rgb(51, 116, 116);
   height: 36px;
   color: azure;
   font-size: 17px;
   border-width: 0px;
   width: 116px;
  }
 </style>
 <apex:form id="pbform">
  <apex:pageMessages />
  <div class="container">
   <h1 class="labelCol vfLabelColTextWrap ">Record Patient Signature:</h1>
   <canvas id="PsignatureCanvas" height="100px" width="350px" style="border: 3px solid antiquewhite; border-radius: 8px;" ></canvas>
  </div><br/>
  
  <div style="margin-left: 41%;">
   <apex:commandButton value="Save Patient Signature" onclick="savePSignature();return false;" styleClass="button"/>&nbsp;&nbsp;&nbsp;
   <apex:commandButton value="Clear" onclick="clearSign();return false;" styleClass="button"/>
  </div>
 </apex:form>

  <script>
  var canvas;
  var context;
  var drawingUtil;
  var isDrawing = false;
  var accountId = '';
  var prevX, prevY, currX, currY = 0;
  var accountId;

   function DrawingUtil() {
   isDrawing = false;
   canvas.addEventListener("mousedown", start, false);
   canvas.addEventListener("mousemove", draw, false);
   canvas.addEventListener("mouseup", stop, false);
   canvas.addEventListener("mouseout", stop, false);
   canvas.addEventListener("touchstart", start, false);
   canvas.addEventListener("touchmove", draw, false);
   canvas.addEventListener("touchend", stop, false);
   w = canvas.width;
      h = canvas.height;
  }

   function start(event) {
   event.preventDefault();
   
   isDrawing = true;
   prevX = currX;
   prevX = currY;
   currX = event.clientX - canvas.offsetLeft;
   currY = event.clientY - canvas.offsetTop;
   
   context.beginPath();
   context.fillStyle = "cadetblue";
   context.fillRect(currX, currY, 2, 2);
            context.closePath();
   
  }

   function draw(event) {
   event.preventDefault();
   if (isDrawing) {
    prevX = currX;
             prevY = currY;
             currX = event.clientX - canvas.offsetLeft;
             currY = event.clientY - canvas.offsetTop;
    context.beginPath();
    context.moveTo(prevX, prevY);
    context.lineTo(currX, currY);
    context.strokeStyle = "cadetblue";
    context.lineWidth = "2";
    context.stroke();
    context.closePath();
   }
  }

   function stop(event) {
   if (isDrawing) {
    context.stroke();
    context.closePath();
    isDrawing = false;
   }
  }
  
  function clearSign() {
   context.clearRect(0,0,w,h);
  }

   canvas = document.getElementById("PsignatureCanvas");
  context = canvas.getContext("2d");
  context.strokeStyle = "black";
  context.lineWidth = "2";
  drawingUtil = new DrawingUtil(canvas);
  

   function savePSignature() {
   var strDataURI = canvas.toDataURL();
   strDataURI = strDataURI.replace(/^data:image\/(png|jpg);base64,/, "");
   var accId = location.href.split('=')[1];
   accountId = accId;
   var result = CapturePSignatureController.savePSignature(strDataURI, accId, processResult);
  }

   function processResult(result) {
   alert(JSON.stringify(result));
   window.location.href = '/'+accountId;
  }

  </script>


</apex:page>

 
Steven MellerSteven Meller
Paul
instead of controller="CapturePSignatureController"  in your page, define it with the standard controller syntax.  Your controller class can still be accessed as it is fully qualified.  standardController="Account" then it will show up in the Account page layout.  But I thought you said you wanted it to appear on the case?
Steve