Can't import RatingFieldServerComponent

Hi,

I’m trying to create a custom GWT component, using the instructions on Creating a GWT component - CUBA Platform. Developer’s Manual. I walked through all of the steps. Now, when I create the RatingScreen controller and try to import
“import com.company.kdodatabase.web.toolkit.ui.RatingFieldServerComponent;”
I get a “Cannot resolve symbol RatingFieldServerComponent” error. I am sure that the RatingFieldServerComponent is in this folder. See screenshot for the error screen and project structure.

Any suggestions what might be going wrong? Thanks.!

Hello @jesse.dijkman

Server component should be located in the web module.

Regards,
Daniil

Thanks @tsarev, you pointed me in the right direction!

This was a bit confusing for me, as in the documentation example the package references for the server component contained “web.toolkit.ui”: that made me think the files should be in the web-toolkit module.

I made the following changes:

  1. moving RatingFieldServerComponent, RatingFieldServerRpc and RatingFieldState to the web module (I kept RatingFieldConnector and RatingFieldWidget in the web-toolkit module)
  2. changing the package references in the files I move to the web module
  3. adding import statements to the moved files in the RatingFieldConnector

However, when I try to remove the RatingFieldServerRpc and RatingFieldState from the web-toolkit module, I get errors:

[ERROR] Errors in ‘file:/C:/Users/JesseDijkman/StudioProjects/KDOdatabase/modules/web-toolkit/src/com/company/kdodatabase/web/toolkit/ui/client/ratingfield/RatingFieldConnector.java’:
[ERROR] Line 22: No source code is available for type com.company.kdodatabase.web.rating.RatingFieldServerRpc; did you forget to inherit a required module?
[ERROR] Line 29: No source code is available for type com.company.kdodatabase.web.rating.RatingFieldState; did you forget to inherit a required module?

How can I resolve these? Am I correct when moving RatingFieldServerRpc and RatingFieldState to the web module? And if not, how do I reference the web-toolkit classes (when I add an import statement from the web module it doesn’t seem to “see” the web-toolkit module).

You should move to the web module only server component and server rpc. State and connector should be placed in web-toolkit module

Ok done, but now the RatingFieldServerComponent in the web module is complaining about the RatingFieldState: “Cannot resolve symbol ‘RatingFieldState’”. When I try to add an import statement for the RatingFieldState class, the RatingFieldServerComponent doesn’t seem to “see” the web-toolkit module. How do I resolve this issue?

Sorry, I’ve mixed up state and widget. Finally, the web module contains: server component, server RPC and state. The web-toolkit module contains component connector and the widget itself.

I have put the files as you told. However, but still having problems referencing the classes in the web module in the RatingFieldConnector. If I don’t add a reference, the used classes aren’t recognized. If I do add a reference, I’m getting some errors (see screenshot).

2019-08-30_125629

Could you try to clear project and re-compile it via gradlew clean assemble?

Please share the project if possible.

I tried, I’m getting: FAILURE: Build failed with an exception.

Attached the modules from my project (whole project is too large to share).

modules.zip (393.5 KB)

A little more info. When I move the Connector and Widget directly into the web-toolkit module (com.company.kdodatabase.web.toolkit.ui), at least the project builds and server can be started. But now, when I open the editor containing the custom GWT component, I get this message (see screenshot). How to resolve this issue? Are the module files I uploaded in my previous comment enough to find the issue? Might be related to: Widgetset does not contain implementation of server component - #2 от пользователя emmett.miller - CUBA.Platform. Thanks.

2019-08-30_200512

Hello @jesse.dijkman

Make sure that server component and client classes (connector and widget) are located in common packages, for example:

  1. com.company.sample.web.widgets.mywidget - for server component
  2. com.company.sample.web.widgets.client.mywidget

Regards,
Daniil

Sorry, I’m a bit confused. I’ve put the classes where you suggested:
-> In web module: RatingFieldServerComponent, RatingFieldServerRpc, RatingFieldState
-> In web toolkit module: RatingFieldWidget, RatingFieldConnector

Do you mean one or more classes should be put elsewhere? And if so, where should I put what?

I managed to fix it. I’ve put all files in the web toolkit module, structured as you told me. Somehow, when generating the webtoolkit module, a dependency was added for the web module. This should be the other way around, so I can reference the widget in the web toolkit module from the web module. I’ve fixed it and now I’m able to use the widget in my web module.

Thanks for your help.