Can we build the server side of widgets in Scala?

Hello!

I am new to Vaadin and I am doing some work integrating existing widgets. I am also familiar with
Scala and was wondering if I could build the server side component in Scala so I could reuse traits and
make code much simpler…

So I have modified the default class to look something like
[font=Courier New]

@com.vaadin.ui.ClientWidget(classOf[com.example.test.client.ui.VMyComponent]
)
class MyComponent extends AbstractComponent {

override def paintContent(target : PaintTarget) = { 

[…]

[/font]

The thing compiles perfectly, but the GWT Compiler doesn’t pick up the component. Is it scanning only
Java files? Is there any way I can force the association even if the compiler isn’t doing it automagically for me ?

Thanks!

I think that this is that only Java files are scanned, as you suspected. It would require support in the widgetset builder to scan other files too. As a quick workaround you might try to create a dummy Java file with the ClientWidget annotation to the same client-side widget - just to trigger the GWT compilation.

I’m not sure what you mean by building the widgets (are you talking custom widgets?), but if you are asking if you can use Vaadin in a Scala app and write your Vaadin code in Scala, then the answer is yes. I am building a Vaadin app right now and everything is in Scala.

There’s an excellent set of
blog posts by Rob Lally
that work you through it.


Mike Nash
has played around with it as well:

Those got me going. It’s remarkably easy.

Good luck.

If I remember correctly the ClassPathExplorer scans for “.class” files and tries to load them to find out if there is a @ClientWidget annotation present. So you need to ensure the classes have been compiled at least for them to be picked up.