简体   繁体   中英

How can I add custom classes to GWT project outside of EntryPoint

I have to take a JavaFX application and translate it into a GWT implementation but I don't fully understand some of the structure of a GWT application.

In my entrypoint class I create all the gwt elements I need, but I want to include some other classes to add some functionality. However whenever I try to compile the GWT project I end up with the following error.

[ERROR] Hint: Check the inheritance chain from your module; it may not be inheriting a required module or a module may not be adding its source path entries properly

The src structure is:

src.com.Application
 |
 +-- Client
 |  |  
 |  +-- Application
 |  +-- ApplicationService
 |  +-- ApplicationServiceAsync
 |    
 +-- Controller
 |  |  
 |  +-- ParameterController
 |  +-- PopupController
 |    
 +-- Server
 |  |  
 |  +-- ApplicationServiceImpl

My Application.gwt.xm l file looks like this:

<module rename-to="Application">

    <!-- Inherit the core Web Toolkit stuff.                  -->
    <inherits name='com.google.gwt.user.User'/>             -->

    <!-- Specify the app entry point class.                   -->
    <entry-point class='com.Application.client.Application'/>

    <!--Specify the GWT style sheet                           -->
    <inherits name='com.google.gwt.user.theme.clean.Clean'/>

    <!-- Specify the app servlets.                   -->
    <servlet path='/ApplicationService' class='com.Application.server.ApplicationServiceImpl'/>

    <source path="com.Application.Controllers.ParameterController" />
</module>

If I remove all references of ParameterController.java in Application.java and comment out the source tag in my Application.gwt.xm file it compiles and opens in chrome with all empty elements without any functionality.

How can I allow for the code outside of Application.java be usable in my gwt project? Is there some specific class ParameterController.java must inherit to be compile-able, if so what?

The client package is only added for compilation if you dont specify any <source/> element, because the default is <source path="Client"> .
In your example the only code that will be compiled by the GWT compiler(and usable on client-side) is your ParameterController .
By also adding <source path="Client"> to your *.gwt.xml file the problem should be fixed.
(Also the package names should not use capitol letters.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM