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
Vincent Charlet (FR)Vincent Charlet (FR) 

Error: Controller not found for JavaScriptSObjectBaseController

 Hello,

i have a VisualForce Page on a public site writing Lead with a Javascrit Remote Object class
<!-- Remote Objects declaration -->
<apex:remoteObjects jsNamespace="RemoteObjectModel">
  <apex:remoteObjectModel name="Lead" fields="Salutation,FirstName,LastName,Phone,MobilePhone,Street,PostalCode,City,LeadSource">
  </apex:remoteObjectModel>
</apex:remoteObjects>


The page works fine and leads are created
but after at least 12h, the create method return an error "Controller not found for JavaScriptSObjectBaseController" !!
(close and re-open the page not work)

The page use HTML5 cache manifest technology (for offline purpose)
Never notice the error on desktop browser but on IPAD with Safari

if i update the cache manifest or delete the ipad site cache, the page works well again .... for 12 hour more ....

any ideas or workaround ?!




 
pconpcon
You say you're using HTML5 cache tech, is this something you wrote yourself?  or is this something that someone else wrote?  It sounds to me like there is some sort of session time out that is occuring and it's "forgetting" about the controller on the page.
Vincent Charlet (FR)Vincent Charlet (FR)
it's a HTML5 feature
https://en.wikipedia.org/wiki/Cache_manifest_in_HTML5
 
pconpcon
I understand that it is an HTML 5 feature.  I was just checking to see if you were using a 3rd party library to manage the cache or if you were doing it yourself.
Vincent Charlet (FR)Vincent Charlet (FR)
no 3rd party library, i let de browser do the job !

below a simple testing version of the 2 pages, put it on a Force.com site, give public access to LeadObject for create (with fields FirstName, LastName, Phone and MobilePhone)
and it works .... wait 24hrs .... and kaboum !!

TestCacheManifest
<apex:page standardStylesheets="false"
showHeader="false"
sidebar="false"
contenttype="text/cache-manifest"
cache="false"
expires="0">CACHE MANIFEST
CACHE:
/LeadCache
NETWORK:
*
</apex:page>

LeadCache
<apex:page id="aPage" standardController="Lead" showHeader="false" sidebar="false" showChat="false" docType="html-5.0" standardStylesheets="false" manifest="/TestCacheManifest" cache="true">
<html>
<head>
  <meta charset="utf-8"></meta>
  <meta name="description" content=""></meta>
  <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1"></meta>


  <meta name="apple-mobile-web-app-capable" content="yes" />
  <meta name="apple-mobile-web-app-title" content="Test Lead Cache" />
  <meta name="application-name" content="Lead Cache" />

  <apex:stylesheet value="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
  <apex:stylesheet value="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" />

  <apex:includeScript value="//code.jquery.com/jquery-1.11.3.min.js" />
  <apex:includeScript value="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" />

  <!-- Remote Objects declaration -->
  <apex:remoteObjects jsNamespace="RemoteObjectModel">
    <apex:remoteObjectModel name="Lead" fields="FirstName,LastName,Phone,MobilePhone">
    </apex:remoteObjectModel>
  </apex:remoteObjects>  

  <style>
    .form-group.required label:after {
      content:" *";
      color:red;
    }
    .dateFormat {
        display: none;
    }
    .ui-datepicker-title {
        color: black;
    }
    .panel-heading {
        padding: 5px 10px;
    }
    .panel-body {
        padding: 0px 15px 15px 15px;
    }        
    h1.panel-heading {
      background-color: #1980B6 !important;
      background-image: none !important;
      margin: 0px 0px;
    }
    #version {
      font-size: 8px;
    }    
  </style>
  
  <script type="text/javascript">

      var $j = jQuery.noConflict(); 

      function isOnline() {
          return navigator.onLine    // For testing correct code is: navigator.onLine
      }

      function resetPage() {
          
          $j('[id="aPage:detailpage"]').each(function() {
            this.reset();
          });

          setTimeout(function(){
              $j('#alertSuccess').fadeOut("slow");
          }, 3000);
      }

      function saveLead(e) {
        e.preventDefault();

        $j('#alertSuccess').hide();
        $j('#alertMandatory').hide();
        $j('#alertError').hide();
        var vNom = $j('[id="aPage:detailpage:aNom"]').val();

        if (vNom != '') {
            var leadObj = {
                  FirstName: $j('[id="aPage:detailpage:aPrenom"]').val(),
                  LastName: $j('[id="aPage:detailpage:aNom"]').val().toUpperCase(),
                  Phone: $j('[id="aPage:detailpage:aTel"]').val(),
                  MobilePhone: $j('[id="aPage:detailpage:aMobile"]').val()
                }
        
            var record = new RemoteObjectModel.Lead();
            record.create(leadObj, function(err, result, event) {
                    if(err) { 
                      console && console.log(err);
                      $j('#alertError').show();
                      $j('#msgError').text(String(err).replace(/&#39;/g, "'"));
                        
                    } else {
                      $j('#alertSuccess').show();
                      resetPage();
                    }
                    });
                
        } else {
            $j('#alertMandatory').show();
            if (vNom == '')
              $j('[id="aPage:detailpage:aNom"]').parent().parent().addClass('has-error');
                
        }
        return true;
      }
      
      jQuery(function($) {
          
          $j('#save').click(function(e) {
              e.preventDefault();
              saveLead(e);
          });       
          $j('#refresh').click(function(e) {
              e.preventDefault();
              $j(this).hide();
              location.reload(true);
          });       
          
      })
      
  </script>
    
</head>
<body style="margin: 3px">
  <div class="panel panel-primary">
    <button id="refresh" class="refresh btn" style="float: right; margin: 10px; border: 1px solid"><span class="glyphicon glyphicon-refresh" aria-hidden="true"/></button>
    <h1 class="panel-heading">
      <div id="version">Version 1.0</div>
    </h1>
    
    <div id="alertSuccess" class="alert alert-success" role="alert" style="display: none;">
      <span class="glyphicon glyphicon-ok-circle" aria-hidden="true"></span>
      <apex:outputText value=" New Lead created !!" />
    </div>

    <div id="alertMandatory" class="alert alert-danger" role="alert" style="display: none;">
      <span class="glyphicon glyphicon-remove-circle" aria-hidden="true"></span>
      <apex:outputText value=" Name is mandatory" />
    </div>

    <div id="alertError" class="alert alert-danger" role="alert" style="display: none;">
      <span class="glyphicon glyphicon-remove-circle" aria-hidden="true"></span>
      <apex:outputText value=" ERROR !!" />
      <div id="msgError"></div>
    </div>

    <apex:form id="detailpage" styleClass="container-fluid panel-body">


      <div class="row">
      <div class="form-group col-md-5">
        <apex:outputLabel value="{!$ObjectType.Lead.fields.FirstName.Label}" styleclass="control-label" for="aPrenom" />
        <apex:inputField id="aPrenom" styleClass="form-control" value="{!Lead.FirstName}"/>
      </div>
      <div class="form-group required col-md-5">
        <apex:outputLabel value="{!$ObjectType.Lead.fields.LastName.Label}" styleclass="control-label" for="aNom" />
        <apex:inputField id="aNom" styleClass="form-control" value="{!Lead.LastName}"/>
      </div>
      </div>

      <div class="row">
      <div class="form-group col-md-5">
        <apex:outputLabel value="{!$ObjectType.Lead.fields.Phone.Label}" styleclass="control-label" for="aTel" />
        <apex:inputField id="aTel" styleClass="form-control" value="{!Lead.Phone}"/>
      </div>
      <div class="form-group col-md-5">
        <apex:outputLabel value="{!$ObjectType.Lead.fields.MobilePhone.Label}" styleclass="control-label" for="aMobile" />
        <apex:inputField id="aMobile" styleClass="form-control" value="{!Lead.MobilePhone}"/>
      </div>
      </div>
      
      <div class="row">
        <div class="col-md-12">
        <button id="save" class="save btn btn-success"><span class="glyphicon glyphicon-pencil" aria-hidden="true"/><apex:outputText value="Create" /></button>
        </div>
      </div>
    
    </apex:form>
  </div>  
</body>
</html>
</apex:page>
and the TestCacheManifest page, very simple

 
Vincent Charlet (FR)Vincent Charlet (FR)
After some more test on my IPAD Air 2, got the error with Safari, not with Firefox
(not find software version)