2011-12-23 92 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。