PDA

View Full Version : How to ensure a proxy goes to the bacjend



ccrosetti
16 Feb 2013, 3:36 PM
Hello, I have a sampe Exkt JS 4.1.3 app designed with a grid, a Store and a Rest Proxy, where the api is defined and url is set to localhost:8080.

The app is deploted on a web server running at port 80 whlie the backend is a Java MVC running on a tomcat at port 8080. Buth web servers running locally in the same PC.

I see the app store goin with the proxy to load data for the store with the right url but still with no port or port 80, lie the url setting in the proxy (localhost:8080) is not taken into account.

What could be wrong?

The code fragment....

Ext.define('ContactGrid.store.user', {
extend: 'Ext.data.Store',
alias: 'store.user',

requires: [
'ContactGrid.model.Contact'
],

constructor: function(cfg) {
var me = this;
cfg = cfg || {};
me.callParent([Ext.apply({
autoLoad: true,
storeId: 'user',
model: 'ContactGrid.model.Contact',
proxy: {
type: 'rest',
api: {
read: '/contact/view.action',
create: '/contact/create.action',
update: '/contact/update.action',
destroy: '/contact/delete.action'
},
url: 'http://localhost:8080/',
writer: {
type: 'json'
},
reader: {
type: 'json'
}
},
sorters: {

}
}, cfg)]);
}
});

existdissolve
16 Feb 2013, 6:30 PM
If I'm reading the docs correctly, I believe the issue you're encountering is that you are basically overwriting the url config by the individual api configs. From the docs:

"The url is built based upon the action being executed [create|read|update|destroy] using the commensurate api (http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.proxy.Server-cfg-api) property, or if undefined default to the configured Ext.data.Store (http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.Store).url (http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.proxy.Server-cfg-url)."

ccrosetti
16 Feb 2013, 7:11 PM
Thanks for sending a quick reply. I am defining the "api" without the protocol+host+port and looking to the tomcat logs I see a well formed http request. What I could say is that the "orl" object seems to be not working.