Skip to content

Instantly share code, notes, and snippets.

View forcementor's full-sized avatar

Don Robins forcementor

View GitHub Profile
@forcementor
forcementor / PocketCRM.store.Leads
Created October 17, 2012 21:25
Developing Mobile…Force.com and Sencha-Part 2, Step 7: Add Apex Remoting - Modify Store
Ext.define("PocketCRM.store.Leads", {
extend: "Ext.data.Store",
requires: "Ext.data.proxy.LocalStorage",
config: {
model: "PocketCRM.model.Lead",
//Fetch the data from the custom Apex controller method
//which will return a simple list of Leads as JSON on load.
@forcementor
forcementor / PocketCRMLeadController2.cls
Created October 17, 2012 21:29
Developing Mobile…Force.com and Sencha-Part 2, Step 7: Add Apex Remoting - Modify Apex Controller
public with sharing class PocketCRMLeadController {
public PocketCRMLeadController() {}
//========================================================================
//INNER CLASSES
//These support data request/response transport for remoting.
//========================================================================
// One of the parameters supplied by the DirectProxy read method.
@forcementor
forcementor / PocketCRM.model.Lead2
Created October 17, 2012 21:31
Developing Mobile…Force.com and Sencha-Part 2, Step 8: Adjusting the Model and Adding a Data Proxy - Modify the Model
//The Lead model will include whatever fields are necssary to manage.
Ext.define("PocketCRM.model.Lead", {
extend: "Ext.data.Model",
config: {
idProperty: 'Id',
fields: [
{
name: 'Id',
@forcementor
forcementor / QueryRequest.Stub
Created October 17, 2012 21:32
Developing Mobile…Force.com and Sencha-Part 2, Step 8: Adjusting the Model and Adding a Data Proxy - QueryRequest stub
...
limitParam: 'recordCount', // maps to QueryRequest.recordCount
...
}
(Apex)
public class QueryRequest {
...
Integer recordCount;
...
@forcementor
forcementor / JSON.Request.Stub1
Created October 17, 2012 21:33
Developing Mobile…Force.com and Sencha-Part 2, Step 8: Adjusting the Model and Adding a Data Proxy - JSON stub
{"action":"PocketCRMLeadController","method":"Edit","data":[[{"LastName":"Rogers","Id":"00Q5000000TXUh7EAH"}]],"type":"rpc","tid":8,"ctx":{"csrf":"RJwzNCf17ZNm_6plAMNqSGf5xEWfwVJcR4CPtjMVb4a2g38HryRgL0jyVfAn2GNyUSd.PHPwsl5sptP607AXKgFvCnGIKGLnvExkZV9ILTLCHMNdIjTHsdKYMwVYe2JNSfnZ8THOvpEld6_.px3lKp3rcx_q7NAX1oClG13LQCYR1BY_","vid":"06650000000D9rZ","ns":"","ver":25}}
@forcementor
forcementor / onSaveLeadCommand.validation1
Created October 17, 2012 21:33
Developing Mobile…Force.com and Sencha-Part 2, Step 8: Adjusting the Model and Adding a Data Proxy - Validation Stub 1
onSaveLeadCommand: function () {
console.log("onSaveLeadCommand");...
//Check for validation errors.
var errors = currentLead.validate();
if (!errors.isValid()) {
var msg = '';
errors.each(function (error) {
msg += error.getMessage() + '<br/>';
@forcementor
forcementor / onSaveLeadCommand.validation2
Created October 17, 2012 21:34
Developing Mobile…Force.com and Sencha-Part 2, Step 8: Adjusting the Model and Adding a Data Proxy - Validation Stub 2
validations: [
{ type: 'presence', field: 'LastName', message: 'Enter a last name.' },
...
@forcementor
forcementor / controller.launch
Created October 17, 2012 21:35
Developing Mobile…Force.com and Sencha-Part 2, Step 8: Adjusting the Model and Adding a Data Proxy - Controller Launch stub
// Base Class functions.
launch: function () {
console.log("launch");
this.callParent(arguments);
//Load up the Store associated with the controller and its views.
console.log("load Leads");
var leadsStore = Ext.getStore("Leads");
leadsStore.load();
},
@forcementor
forcementor / controller.init
Created October 17, 2012 21:36
Developing Mobile…Force.com and Sencha-Part 2, Step 8: Adjusting the Model and Adding a Data Proxy - Controller Init stub
init: function () {
this.callParent(arguments);
console.log("init");
//Listen for exceptions observed by the proxy so we can report them and clean up.
//20121016 Fixed for bug on improper object references
Ext.getStore('Leads').getProxy().addListener('exception', function (proxy, response, operation, options) {
// only certain kinds of errors seem to have useful information returned from the server
if (response) {
if (response.errorMessage) {
@forcementor
forcementor / getArgs.stub
Created October 17, 2012 21:36
Developing Mobile…Force.com and Sencha-Part 2, Step 9: Adjusting Our Proxy To Work With Visualforce Remoting - Controller Tweaks 1
//Adjust our read method to add a function that Touch expects to see to get Arguments.
PocketCRMLeadController.Query.directCfg.method.getArgs = function (params, paramOrder, paramsAsHash) {
console.log('getArgs: ' + params.data);
return [params]
}