Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Compile classes in the widgetset
I tryed to follow this tutorial to extend one of my component : https://vaadin.com/blog/-/blogs/2656782
I created both classes ResetButtonForTextField and ResetButtonForTextFieldConnector that I put in com.myproject.widgetset.extendedComponents in src/main/java in my WidgetSet project.
After compilation (the widgetset is also compiled) and adding in my code :
TextField tf = new TextField(); ResetButtonForTextField.extend(tf);
It seems like the extend is not working because I put heaps of logs in the ResetButtonForTextFieldConnector class and nothing is displayed in my app logs when I'm using the textfield. I think it's cause of the ResetButtonForTextFieldConnector isn't compiled when the widgetset is compiling because I saw that at the end of the tutorial :
"An extension connector needs to be included in a widget set. The class must therefore be defined under the client package of a widget set, just like with component connectors."
So I probably forgot something or maybe I'm doing something wrong that's why I'm asking for help here because I'm stuck !
If anybody could help or advice me :)
Try putting the connector in com.myproject.widgetset.client or in com.myproject.widgetset.client.extendedComponents and recompile the widgetset.
Also: The logs you put in your connector won't appear in the Server logs as the connector is running on the client side. You could see them if you're debugging the client side (google "Vaadin debug client side" to find documentation)
You are right ! It's exactly that !
I renamed my package in com.myproject.widgetset.client.extendedComponents and during the widgetset compilation I can see that my classes are trying to be compiled !
But now I get a strange compilation error, it says :
[INFO] Compiling module com.refComp.widgetset.MyAppWidgetset [INFO] Tracing compile failure path for type 'com.refComp.widgetset.client.extendedComponents.ResetButtonForTextField' [INFO] [ERROR] Errors in 'file:/Users/TCT/Desktop/TomChanussot/project/RefComp/RefComp-widgetset/src/main/java/com/refComp/widgetset/client/extendedComponents/ResetButtonForTextField.java' [INFO] [ERROR] Line 10: No source code is available for type com.vaadin.ui.TextField; did you forget to inherit a required module? [INFO] [ERROR] Line 7: No source code is available for type com.vaadin.server.AbstractExtension; did you forget to inherit a required module? [INFO] [ERROR] Line 11: No source code is available for type com.vaadin.server.AbstractClientConnector; did you forget to inherit a required module? [INFO] [ERROR] Aborting compile due to errors in some input files
However I have the following dependencies in the pom.xml :
<dependencies> <dependency> <groupId>com.vaadin</groupId> <artifactId>vaadin-client</artifactId> </dependency> <dependency> <groupId>com.vaadin</groupId> <artifactId>vaadin-client-compiler</artifactId> </dependency> <dependency> <groupId>com.vaadin</groupId> <artifactId>vaadin-server</artifactId> </dependency> <dependency> <groupId>com.vaadin</groupId> <artifactId>vaadin-push</artifactId> </dependency> <dependency> <groupId>com.vaadin</groupId> <artifactId>vaadin-themes</artifactId> </dependency> </dependencies>
Is there something that I forget... ?
It seems like you also put the server side class called ResetButtonForTextField in the widgetset.client package. Everything in the client package doesn't have access to server side classes like com.vaadin.ui.Textfield....hence the exceptions during compilation.
ResetButtonForTextField should be in a "server-side" package (which are pretty much all packages expect the ones under widgetset) like just as an example: com.refComp or com.refComp.extensions or something like this while the connector and all RPCs should stay in the widgetset.client package.