开发者

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 开发者_Python百科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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜