Tuesday, July 12, 2016

Re: Cascading GWT Application ?

I suggest these layouts:

Single Java project:

/src/main/java
   
/app1
        app1
.gwt.xml
       
/client
   
/app2
        app2
.gwt.xml
       
/client
   
/menu
        menu
.gwt.xml
       
/client
   
/commons
        commons
.gwt.xml
       
/client
       
/shared
   
/server

Explanation:

"App1" and "App2" are the two separate applications, which one in their own host page. They can be accessed independently. "Menu" is just another application with its own host page, but depends on "App1" and "App2". "Commons" is a lib project, in other words, not an application, but a collection of resources shared by all other projects. Put there any client or shared code that will be used by the other modules. "Server" is not a GWT Module, it's just a package with the server code and the business logic.

Since every module will depend on "Commons", anything you define on its gwt.xml file will be inherited by the other modules.

Multiple Java Projects:

/app1
    /
src/main/java/app1
        app1
.gwt.xml
       
/client

/app2
    /src/main/java/app2
        app2
.gwt.xml
       
/client


/menu
    /src/main/java/menu
        menu
.gwt.xml
       
/client

/commons
    /src/main/java/commons
        commons
.gwt.xml
       
/client
        /shared

/server
    /src/main/java/server


When using multiple Java projects you need not only to deal with the dependency among GWT modules but also the dependency among Java projects: "Menu" project will depend on "App1" and "App2", which will both depend on "Server", and "Server" will depend on "Commons". This way the dependency chain is formed, and there's where you put Maven to work.

This approach is better if you want separate artifacts/archives (.war) for each project. With each project in its own .war file you can deploy them on different servers at different locations. If you only need three different html pages within the same server, I suggest the single project layout.

Of course those are only suggestions. They assume that you have a single server code that can be accessed by any of the apps. If you need a separate server logic that only some of the apps should have access to, then you should create multiple server projects.

There are some threads talking about multiple module GWT projects you should read (if haven't already):

http://stackoverflow.com/questions/2274601/gwt-multiple-modules
https://groups.google.com/forum/#!topic/google-web-toolkit/DYVZj4WzjEU
https://groups.google.com/forum/#!topic/google-web-toolkit/wndMtcm4hR4

In general I suggest you not to mix multiple compiled modules (*.nocache.js) on the same HTML hosting page. If you need to mix two modules on the same page, create a third project that depends on both modules and create a single *.nocache.js for it.

If you want to go crazy you can put Maven modules in the mix (on top of GWT modules and Java projects), but for now you should focus on having a running project.

Hope it helps =)

--
Gilberto

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment