Hi to all,
I'm developing an extjs application using MVC pattern.
I have a form with a store defined like this
Code:
// The new DataWriter component.
var writer = new Ext.data.JsonWriter({
encode : false
});
Ext.define('AM.store.nwkview.NwkPanel1', {
extend : 'Ext.data.DirectStore',
requires : 'Ext.direct.*', // use ext-direct for binding
/**
* The model of the data of the store
*/
model : 'AM.model.nwkview.NwkPanel1',
autoLoad : true,
constructor : function(config) {
config = config || {};
config.proxy = {
/* Accept direct methods */
type : 'direct',
extraParams: {'networkId':0},
paramOrder:['networkId'],
/* API interface */
api : {
read : NetworkView.getPanel1,
update : NetworkView.updateNwkConfig
// destroy : undefined
},
/* The reader and the writer */
reader : {
type : 'json',
root : 'result'
},
writer : writer,
paramsAsHash : false
};
this.callParent([config]);
},
load : function(record) {
....
....
}
});
Now, Is it possible to call the store update function from the component's controller to submit it to the server side?
This is the way I found in some documents across the web but store.sync() won't call the server method specified:
Code:
init : function() {
console.log('init function in panel Controller has been called... ');
this.control({
'editpanel[store="nwkview.NwkPanel1"] >> tool[type="save"]' : {
click : function(th, e, eOpts) {
var store = this.getStore("nwkview.NwkPanel1");
debugger
store.sync();
}
}
});
}
My server method is the following:
Code:
@DirectFormPostMethod
public void updateNwkConfig(Map<String, String> formParameters,
Map<String, FileItem> fileFields) throws Exception {
WebContext context = WebContextManager.get();
if(context==null)
Utils.ERROR_WEBCONTEXT_NULL("Network View", "updateNwkLabel");
log.info("CALLED!");
I tried also:
Code:
@DirectMethod
public void updateNwkConfig(JsonElement newlabel) throws Exception {
WebContext context = WebContextManager.get();
if(context==null)
Utils.ERROR_WEBCONTEXT_NULL("Network View", "updateNwkLabel");
log.info("CALLED!");
}
but this won't work too
Any suggestions?
Thanks for your help.
M