Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GWT - adding external java classes to client project

I have a GWT project. Client code is located in the "client" dir. I want to attach an external java classes (mainly plain POJO DTO classes) that are in external directory. How to configure the gwt.xml file?

I get errors of this kind:

[ERROR] Errors in 'file:/C:/development/projects/CodeSpaces/LocateMe/LocateMeWeb/src/com/dominolog/locateme/client/LocateMeWeb.java' [ERROR] Line 56: No source code is available for type com.dominolog.locateme.model.dto.LocationInfo; did you forget to inherit a required module?

like image 653
cubesoft Avatar asked Jan 23 '23 12:01

cubesoft


2 Answers

If you have the java source files you just need to add the directory to you .gwt.xml file. For instance if you had a subdirectory called shared you would add the following line:

<source path='shared'/>

The folder called shared would have to be one level under your main package. So if you project .gwt.xml file is at com.yourdomain.project the shared folder.package would be com.yourdomain.project.shared. Refer to the Source Path section at http://code.google.com/webtoolkit/doc/latest/DevGuideOrganizingProjects.html#DevGuideModules

If you dont have the source and only have the classes you have to import a module as Hilbrand has stated.

like image 119
Carnell Avatar answered Jan 25 '23 01:01

Carnell


Here is another solution that works http://www.gordonizer.com/2012/01/referencing-third-party-library-source.html .

I short (just in case this link also gets invalid some day):

  • Suppose the external package containing the classes you want to add is com.foo.bar.bat.
  • In your project, you create package com.foo.bar (without the subpackage bat).
  • In your new package you create a new GWT module file Foo.gwt.xml with content like

    <module> <source path="bat" /> </module>

    (I have ommitted the XML header for sake of readability)

  • Finally add this new module to your main GWT module using the inherit tag:

    <inherits name="com.foo.bar.Foo"/>

like image 25
rainer198 Avatar answered Jan 25 '23 01:01

rainer198