0

I am working on a Java web app- it will use GWT for the front end.

I understand that for the package com.abc.xyz, client side code will be in com/abc/xyz/client, while server side code will be in com/abc/xyz/server

The same web app also has some purely java code, eg a listener which waits for new items to be added to a queue- the application should then process items in the queue.

This code is partly in the package com.abc.xyz, as well as in some other packages- com.qwerty.package and com.pqr.zzz

Am I correct in thinking that the above type of app can be created as a combination of GWT and Java code?

How do I arrange the code of the packages mentioned above, in my src folder. Also, how do I get the final application- which consists of some pages created using GWT, as well as some purely server side code (like listeners)- will the entire generated code (consisting of JS/HTML from GWT and server side Java code used by GWT as well as pure Java code used by server side listener)- do I run it as web application under Google Menu in Eclipse? Will this automatically create the desired java war file correctly?

Also, I plan to use Smart GWT for the front end part- will this mean some change in the procedure when compared to pure GWT applications?

4 Answers 4

2

I suggest that you organize your code in three packages: - client package for all code that is compiled by the GWT compiler and not used server-side - server package for code that is exclusively used server-side - shared package for code that is used both server-side and client-side (hence compiled). In your gwt.xml file:

<source path="client" />
<source path="shared" />

Note that 'shared' code run on the server cannot invoke some functions like GWT.create(). You typically store you data transfer objects here that are used in RPC calls.

If you use the Eclipse plugin and create a template project with sample content, you'll be good to go. If you're using a third party library like smartgwt, you have to add it your build path and include a line in your gwt.xml so the compiler can find it.

<inherits name="" />
1

Am I correct in thinking that the above type of app can be created as a combination of GWT and Java code?

GWT is Java code, the client part will be compiled into Javascript. You can use any Java API in the services on the server side, in my current project I'm using among others Swing, JPA, Hibernate, Guice, log4j and access MongoDB and Mysql databases.

How do I arrange the code of the packages mentioned above, in my src folder.

This is my layout:

src/main/java:
org.foo.bar.client - GWT client code (activities, events, MVP, places, entry point class)
org.foo.bar.controller - one Swing MVC Controller for my login page (I handle login outside of GWT at the moment)
org.foo.bar.security - My Spring Security classes (Authentication Listener/Provider etc.)
org.foo.bar.server.repository - Spring JPA repositories
org.foo.bar.server.service - RPC services
org.foo.bar.shared - domain classes (JPA entities), they are used both by the client and server
src/main/resources:
org/foo/bar/client/ - property files (constants and messages) for internationalization
META-INF/persistence.xml - for JPA
log4j - logging configuration

do I run it as web application under Google Menu in Eclipse

A GWT project generated in Eclipse contains a working ant build script that can create a war for you. You can then deploy it in your web container of preference like Tomcat, Jetty... However the compilation (the part that generates the client javascript) takes a long time so for testing use the GWT development mode in Eclipse - you'll have to install a plugin for your web browser to take advantage of it.

0

you can use eclipse for all gwt app. it has good plugin for it comes with gui. you also need to install a app engine to you browsers while testing.It will be suggested when you try to test the code in browser automatically.

if you want to use ready java code in project as i know you would use for logic code since gui part is parsed to java to javascritp in gwt so you need to implement in gwt way java.

1
  • @Erogol- your answer is very generic, kindly answer the points I have asked about, in detail...thanks
    – Arvind
    Commented Mar 16, 2012 at 7:44
0

Please refer to the following Link for packaging an Enterprise Application

http://code.google.com/webtoolkit/articles/mvp-architecture.html

I hope this helps you. Also, its a good practice of using Maven along with GWT so that you can divide the Project into simple modules, then build them to make up a large scale application.

Not the answer you're looking for? Browse other questions tagged or ask your own question.