0

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

在 model.groovy 中声明的组件:

Component('ComposeLoading') {
  //fields
  date_time  'etd'

  //reference
  reference 'offerPlan', ref:'OfferPlan'

  //lists
  list 'loadings', ref:'Loading'
  list 'transportOrders', ref:'TransportOrder'
}

在 view.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')
          }
        }
      }
    }
  }
}

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

请在堆栈跟踪下方找到:

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)
...
4

1 回答 1

0

Reading your view name, it seems that you use it in a wizard action. The wizard action does not use a standard model as you would expect (e.g. a ComposeLoading component instance), but it binds a Mapinstance as root model of its views. It is completely transparent to the Jspresso binding layer since it can operate indifferently on Java beans (using accessors) or maps (using getXXX() and putXXX()).

However, the standard collection actions that operate on model dependent collections (like adToMasterFrontAction or removeFromMasterFrontAction) are not that versatile and do not play well with maps... This is definitely a bug and I've opened an issue in the Jspresso GitHub for it.

于 2015-04-24T13:47:12.253 回答