组件上的addToMasterFrontAction失败:“object不是声明类的实例”

时间:2015-04-24 07:38:12

标签: jspresso

我的用例: 我正在使用基于组件作为模型的视图。 在此视图中,我想要一个操作,以便在列表中添加新行。

在model.groovy中声明的组件:

border('ComposeTrain.wizard.first.view', model:'ComposeLoading') {
  north {
    form {
      fields {
        propertyView name:'etd'
        propertyView name:'offerPlan'
      }
    }
  }
  center {
    split_horizontal {
      left {
        table(permId:'ComposeLoading.loadings.table',
               model:'ComposeLoading-loadings',
               selectionMode:'MULTIPLE_INTERVAL_CUMULATIVE_SELECTION')
      }
      right {
        split_vertical(cascadingModels:true) {
          top {
            table(permId:'ComposeLoading.transportOrders.table',
                  model:'ComposeLoading-transportOrders')
            {
              actionMap () {
                actionList('TRANSPORT_ORDER') {
                  action(ref:'addToMasterFrontAction')
                }
              }
            }
          }
          bottom {
            table(permId:'ComposeLoading.TransportOrders.loadings.table',
                   model:'TransportOrder-loadings')
          }
        }
      }
    }
  }
}

view.groovy中声明的视图:

ERROR <2015-04-24 08:48:44,014> org.jspresso.framework.application.frontend.controller.AbstractFrontendController : An unexpected error occurred for user demo on session 6b2afee4.
java.lang.RuntimeException: java.lang.IllegalArgumentException: object is not an instance of declaring class
  at org.jspresso.framework.util.accessor.bean.BeanCollectionAccessor.addToValue(BeanCollectionAccessor.java:78)
  at org.jspresso.framework.application.backend.action.AbstractAddCollectionToMasterAction.execute(AbstractAddCollectionToMasterAction.java:116)
  at org.jspresso.framework.application.backend.AbstractBackendController.execute(AbstractBackendController.java:393)
  at org.jspresso.framework.application.frontend.controller.AbstractFrontendController.executeBackend(AbstractFrontendController.java:1534)
  at org.jspresso.framework.application.frontend.controller.AbstractFrontendController.execute(AbstractFrontendController.java:574)
  at org.jspresso.framework.application.action.AbstractAction.execute(AbstractAction.java:114)
  at org.jspresso.framework.application.frontend.action.std.AddCollectionToMasterAction.execute(AddCollectionToMasterAction.java:85)
  at org.jspresso.framework.application.frontend.controller.AbstractFrontendController.executeFrontend(AbstractFrontendController.java:1547)
  at org.jspresso.framework.application.frontend.controller.AbstractFrontendController.execute(AbstractFrontendController.java:576)
  at org.jspresso.framework.view.remote.RemoteActionFactory$ActionAdapter.actionPerformed(RemoteActionFactory.java:235)
...

我的问题: 当我运行应用程序并单击“添加”按钮时,addToMasterFrontAction失败,并显示:“object不是声明类的实例”

请在下面找到stacktrace:

import sys

if sys.version_info[0] == 2:  # Not named on 2.6
    access = 'wb'
    kwargs = {}
else:
    access = 'wt'
    kwargs = {'newline':''}

with open('test.csv', access, **kwargs) as csv_file:
    writer = csv.DictWriter(csv_file, ['header1', 'header2'])
    writer.writeheader()
    for item in items:
        writer.writerow(item)

1 个答案:

答案 0 :(得分:0)

读取您的视图名称,似乎您在向导操作中使用它。向导操作不像您期望的那样使用标准模型(例如<div class="row"> <div class="col-md-4 col-sm-6"> <?php foreach ($this->popularBook as $popularBook) { echo 'Item Details'; } ?> </div> <div class="col-md-4 col-sm-6"> <p>Item Details</p> </div> <div class="col-md-4 col-sm-6"> <p>Item Details</p> </div> </div> 组件实例),但它将ComposeLoading实例绑定为其视图的根模型。它对Jspresso绑定层完全透明,因为它可以在Java bean(使用访问器)或映射(使用MapgetXXX())上无差别地运行。

但是,对依赖于模型的集合(如putXXX()adToMasterFrontAction)进行操作的标准集合操作并不是那么通用,并且不适合使用地图......这绝对是一个错误,我和我#39;已在Jspresso GitHub中打开了issue