how do I express a Vaadin BeanItemContainer construtor in Scala?

Hi,

I’m trying to load a bunch of com.mongodb.DBObject objects in to a Vaadin BeanItemContainer to display in a table. I’m getting stuck on the translation of the constructor from Java to Scala.

The constructor definition is:

[code]

BeanItemContainer(Class<? extends BT> type)
[/code]

This passes the scala compiler:

[code]

val bic = new BeanItemContainer(Class.forName(“com.mongodb.DBObject”))
[/code]

However, when I try to add an item:

[code]

mtl.toArray.foreach {t => bic.addBean(t)}
[/code]

I get the following error:

 [ERROR]
com/sentientswarm/traderdashboard/UploadTradesWindow.scala:140: error: type mismatch;
     found   : t.type (with underlying type com.mongodb.DBObject)
     required: ?0 where type ?0
                mtl.toArray.foreach {t => bic.addBean(t)}

Any thoughts/suggestions?

Thanks,
John

Try this:

val bic = new BeanItemContainer(classOf[com.mongodb.DBObject]
)

If you use Class.forName, the type of bic will be BeanItemContainer[_]
, not BeanItemContainer[DBObject]
. That doesn’t work with addBean because the parameter wouldn’t have a specific type.