无法使用grails控制器保存extjs组合

时间:2010-04-09 16:09:16

标签: combobox extjs grails-controller

我是grails / extjs的新手我正在为我的团队开发基于Web的配置工具。我的问题是使用extjs的组合框我有三个远程combox(多对一hibernate mappng)。我使用hiddenName提交它value字段(这是数据库的id primay键)而不是它的显示字段,这是我通过将其渲染为json.some得到的名称,我怎么看,如果我选择不同于从db加载的diff索引并尝试更新它。它确实将它作为参数发送,但在保存grails的方法中它没有更新。

我想明白为什么? 我已经粘贴了combobox和grails方法的片段吗?

{
           xtype : 'combo',
           id:'cpsServerid',
           fieldLabel : 'CpsServer',
           name : 'cpsServer',
            //hiddenId:'cpsID',
            hiddenName:'cpsID',
               store: cpsServerStore,
            displayField:'NAME',
            valueField:'ID',
            editable:true,
            typeAhead:true,
            mode:'remote',
            triggerAction:'all',
                  width:300,
            autoScroll:true,
            selected:name,
            selectOnFocus:true},

GRAILS SAVE

 def saveApplicationSubscription = {
         println "saveApplicationSubscription, params = $params"
         ApplicationSubscription subscription 

  if (params.id) {
           subscription  =  ApplicationSubscription.get(params.id as int)
           subscription.cpsServer = CpsServer.get(params.cpsID as int)
           subscription.topic =  params.topic
              subscription.description = params.description
              subscription.subscriberApplication = SubscriberApplication.get(params.subAppID as int)
              subscription.outputQueue = OutputQueue.get(params.outputID as int)
              bindData(subscription , params)
        }
   else {
           params.id = 0
           subscription = new ApplicationSubscription(params)
           subscription.id = params.id as int 
           subscription.cpsServer = CpsServer.get(params.cpsID as int )
           subscription.topic =  params.topic
           subscription.description = params.description
           subscription.subscriberApplication = SubscriberApplication.get(params.subAppID as int)
           subscription.outputQueue = OutputQueue.get(params.outputID as int)
         //  subscription.messageFormat = params.messageFormat


       }
if (subscription.save()) {

         log.info("Saved ApplicationSubscription $subscription")
         render([success: true] as JSON)

     }
     else {
         log.info("Failed to save ApplicationSubscription $subscription, errors = ${subscription.errors}")
         render([success: false, errors: subscription.errors] as JSON)
     }
 }

我真的会提供任何帮助

1 个答案:

答案 0 :(得分:0)

您是否在Firebug控制台选项卡中验证了您的POST看起来像您期望的那样?这将确认您的问题是否在客户端或服务器上。