0

My use case : I am using a view which is based on a component as model. In this view, I want an action in order to add a new row to the list.

The component declared in model.groovy :

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

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

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

The view declared in 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')
          }
        }
      }
    }
  }
}

My problem : when I run the application and when I click on the Add button, the addToMasterFrontAction fails with : "object is not an instance of declaring class"

Please find below the stacktrace :

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)
...
Ygor
  • 35
  • 7
  • I don't see anything obvious in the view description. I seems to be well declared and the `ComposeLoading.addToTransportOrders(...)` method should be called on your main model, i.e. the `ComposeLoading` instance. Could you post the error stacktrace ? – Vincent Vandenschrick Apr 24 '15 at 10:28
  • Please find below the stacktrace : – Ygor Apr 24 '15 at 11:11
  • I added the stacktrace to my question. – Ygor Apr 24 '15 at 11:18

1 Answers1

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.