container = new BeanContainer[Int, Association]
(classOf[Association]
) {
}
[/quote]As a further complication the parameter passed to the BeanContainer constructor needs to be the class of a mixin. i.e., (classOf[Association with SurrogateIntId]
) due to the way my ORM layer (mapperdao) works.
Unfortunately classOf[…]
won’t accept a mixin. Perhaps someone whose scala knowledge is greater than mine could provide some assistance?
Otherwise this all looks like becoming a bit of a mess and it might be better to avoid use of Bean Container entirely unless someone’s done this before.
After battling with various Java/Scala compatibility issues the following is the best I’ve come up with:
p.setContainerDataSource(new BeanContainer[Int, Association]
(classOf[Association]
) {
val associations = associationDao.all
associations foreach { association =>
addItem(association.id, association)
}
})
Had to use “addItem(…)” and manually extract the “id” property from the bean instead of “addBean(…)” to work around the issue where "classOf[…]
" couldn’t be used with a mixin.
And had to fallback to using “p.setContainerDataSource(…)” instead of just “container =”. Is there any way to use the Scaladin approach of “container =” to assign the BeanContainer instance?