2011-12-23 80 views
0

我想使用Play數據綁定與extjs。 我創造了這樣的ExtJS的數據存儲:ExtJS和Play!框架

Ext.define('Account', { 
    extend : 'Ext.data.Model', 
    fields : [{ 
     name : 'description', type: 'string' 
    }, { 
     name : 'accountNumber', type: 'string' 
    }] 
}); 

store = Ext.create('Ext.data.Store', { 
    model: 'Account', 
    proxy: { 
      type: 'ajax', 
      autoSave: false, 
      api: { 
       read: 'account/research', 
       create: 'account/new', 
       update: 'account/update', 
       destroy: 'account/delete' 
      }, 
      reader: { 
       type: 'json' 
      }, 
      writer: { 
       type: 'json', 
       writeAllFields: true, 
       encode: false 
      } 
    } 
}); 

如果我這樣做:

var compte = Ext.create('Account', { 
    description: 'test' 
}); 
store.create(0, compte); 

,但在我的控制器:

public static void new(Account account) { 
    account.save(); 
    renderJSON("{success: true}"); 
} 

所有字段爲空。 我想這是因爲字段必須有像account.description和account.accountNumber前綴在我的POST請求

感謝

回答

0

對不起,我不熟悉的比賽,但在Grails的(非常類似於它),你必須在調用Domain對象的save()之前先做一點數據綁定。像這樣

Account account = new Accouunt(params) 

Account account = new Account() 
account.properties = params 

編輯:跑通過一些遊戲文檔,我想你是做正確的服務器端。在客戶端,您可以嘗試使用「nameProperty」配置。您可能必須定義一個適合Play預期名稱的屬性,並將其用於nameProperty。