Results 1 to 2 of 2

Thread: MVC Form submit changes to the server using direct proxy

  1. #1
    Sencha User
    Join Date
    Jan 2013
    Posts
    1
    Vote Rating
    0
      0  

    Default MVC Form submit changes to the server using direct proxy

    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

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,422
    Vote Rating
    1271
      0  

    Default

    The sync method is the correct means. Is there any actual changes in the store to send?
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •