Widgets and Scala

I’ve come up against the issue where @ClientWidget does not seem to work for the server-side widget class in Scala. Following some previous but unsolved forum posts led me to checking out .class files and so on. Interestingly all the .class files get generated and on inspection the server-side .class file seems to reference the annotation. But…it still fails at runtime.

Of course as you’d expect reverting back to Java makes everything work. There is a work-around though.

For example, say you’re creating a widget called ‘MyComponent’. Create the following files:


The ‘MyComponentStub.java’ is a dummy class used to get the widget builder to notice the annotation for the client-side class.

public class MyComponentStub extends AbstractComponent {

‘MyComponent.scala’ then simply extends from it and implements the required overrides and custom widget code:

class MyComponent extends MyComponentStub {
    // Custom widget overrides and code here

I’m mentioning this solution in case anyone has a better workaround that doesn’t include generating a dummy class just the get the annotations recognised. The ideal would be ditching the dummy stub class and even having the client-side as Scala but I don’t think that’s going to happen any time soon. :slight_smile: