简体   繁体   中英

Using OOP When Programming In GWT?

I have just started to attempt to learn GWT and have run into some confusion. I have setup the following project:

  • com.example.myapp
    -myapp.gwt.xml //defines entrypoint as ...client.myapp

  • com.example.myapp.client
    -myapp.java //implements entrypoint

Now i this works in the web browser, meaning i can add widgets to the rootpanel and have them display and such.

Now i would like to add my own objects to the project i add the following package which will contain the these new classes.

  • com.example.myapp.shapes
    -basicshape.java (abstact class)
    -rectangle.java (extends basicshape)

Now when i then goto then creates objects of the type rectangle, i first make sure that my myapp.java can see and access the shapes:

import com.example.myapp.shapes.rectangle

and then do the standard initialization: rectangle newrect = new rectangle();

I then run the application, and then get the following error:

No source code is available for type com.goodall.myapp.shapes.rectangle; did you forget to inherit a required module?

Now, i cant quite seem to get what is exactly wrong with my little app? Any ideas?

Thanks for any suggestions.

Classes that are intended to be used on the client's side (compile by GWT) should be placed somewhere under client directory. You can also override it by .gwt.xml file, but for simple setup placing them inside com.example.myapp.client.shapes for example will help. Btw, you should read Java code style guidelines. You shouldn't start your class name with small letter.

Add the folder of the client source code to the .gwt.xml file.

  <source path='shapes'/> 

Where the .gwt.xml file resides in the same root as the "shapes" folder.

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