To integrate an Ext JS 4 UI with SalesForce.com and have run into a number of interesting challenges.
One of the issues that we ran into pertains to how remote Ext JS 4 combo boxes transmit query data to the back-end in order to perform incremental searches. Out of the box, whatever the user types into the combo box is transmitted over the uri, e.g. getmydata.aspx?query=somethingITypedIntoAComboBox. The problem is that the salesforce transport mechanism that we’re using only carries forward data passed in the http header, ignoring everything passed on the url.
We wound up modifying the combo box to transmit query data over a Store’s proxy header by setting up a combo box listener that dynamically changed the related store’s proxy header as illustrated below:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
| { xtype: 'combo' , listeners: { beforequery: function (queryPlan,eopts) { this .store.on( 'beforeload' , function (store,operations,eopts) { Ext.apply(store.proxy.headers, { query:queryPlan.query }); }); }, afterquery: function (queryPlan,eopts) { this .store.un( 'beforeload' ); store.proxy.headers.query= null ; } }, store: s, displayField: 'Name' , valueField: 'Id' , typeAhead: false , hideLabel: true , hideTrigger: true , anchor: '100%' , listConfig: { loadingText: 'Searching...' , emptyText: 'No matching posts found.' , // Custom rendering template for each item getInnerTpl: function () { return ' ; } }, pageSize: 10 } |
The underlying Store used the SalesForce.com services proxy:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| Ext.define( 'MyApp.store.MyStore' , { extend: 'Ext.data.Store' , storeId: 'MyStore' , idProperty: 'Id' , fields: [ { name: 'Id' } , {name: 'Name' }, {name: 'BillingCity' }], proxy: { type: 'rest' , url: '/services/proxy' , headers: { 'SalesforceProxy-Endpoint' : serverURL + PATH, 'Authorization' : 'OAuth ' + SESSION_ID } } }); |
The serverUrl and session ID are dynamically output at runtime from SalesForce’s apex architecture:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| < apex:page docType = "html-5.0" sidebar = "false" showHeader = "false" standardStylesheets = "false" cache = "true" applyBodyTag = "false" > < html lang = "en" > < head > < meta charset = "utf-8" /> < script src = "{!URLFOR($Resource.ExtJS,'ext-all.js')}" ></ script > < link rel = "stylesheet" href = "{!URLFOR($Resource.ExtJS,'ext-theme-neptune-all.css')}" /> < script type = "text/javascript" > var SESSION_ID = '{!$Api.Session_ID}'; var serverURL = '{!SUBSTITUTE(SUBSTITUTE(LEFT($Api.Partner_Server_URL_210, FIND( '/services', $Api.Partner_Server_URL_260)), 'visual.force', 'salesforce'), 'c.', '')}'; // If its a mydomain enabled org, the mydomain name needs to be stripped var splitURL = serverURL.split(/\./g); if(splitURL.length==4) { splitURL[0] = 'https://'; serverURL = splitURL.join(".").replace('.',''); } var PATH = 'services/apexrest/XN/Account'; </ script > |
Vmorrcosdibu Jason Harris https://wakelet.com/wake/2mWDIUSZQeqcI3Y7s18ep
ReplyDeletemendelevo
orbaptemppu Jensen Alfonso MorphVOX Pro
ReplyDeleteVMware Workstation
Cinema 4D
nodenkirchvab
liodentinc_me-Washington Erica Cain Free download
ReplyDeletescoutareshos