Tuesday, August 2, 2016

Re: Cascading GWT Application ?

Hey there. 
I come back there to give you my final approach of this problem.

I create a Main Module who inherits of all my needed modules and specify my onlyone entry-point. It looks like that : 
<module rename-to='main'>

   
<inherits name='com.google.gwt.user.User' />
   
<inherits name='com.google.gwt.user.theme.clean.Clean' />

   
<inherits name='garandeau.gwt.it7.menunav.MenuNav'/>
   
<inherits name='garandeau.gwt.it7.module.app1.App1'/>
   
<inherits name='garandeau.gwt.it7.module.app2.App2'/>
   
<inherits name='garandeau.gwt.it7.module.app3.App3'/>

   
<inherits name='org.gwtbootstrap3.GwtBootstrap3' />
   
<inherits name='org.gwtbootstrap3.extras.animate.Animate' />
 
   
<entry-point class='garandeau.gwt.it7.main.client.Main' />
 
   
<public path='resource'>
       
<include name='css/*.css'/>
       
<include name='js/*.js'/>
   
</public>

   
<stylesheet src='css/bootstrap.cerulan.css'/>
 
 
<source path='client' />
 
<source path='shared' />

 
<add-linker name="xsiframe" />
</module>

Java side I manage my applications (modules) states and their history. It's a kind of router for all my webapp.
For that in my onModuleLoad I initialise my History.addValueChangeHandler function with all known states of my modules, then, and I charge them in a declared "divMain" div in my html with a public function like that :

public void chargeMainModule(String appName, String state) {
RootPanel.get("divMain").clear();

App1 app1;
App2 app2;

switch (appName) {
case "Init":
app1 = new App1();
app1.onModuleLoadByMain("divMain");
app2 = new App2();
app2.onModuleLoadByMain("divMain");
break;
case "App1":
 app1 = new App1();
app1.onModuleLoadByMain("divMain");    // The string argument is the div's name to charge the module.
addInUrl("mod", "App1", 0); // addInUrl is the main's function to manage a key and a value in the url at the specified lvl.
break;
case "App2":
app2 = new App2();
app2.onModuleLoadByMain("divMain");
addInUrl("mod", "App2", 0);
break;
default:
break;
}
}

Then, I create my other modules with their own inherits and without entry-point ! It's my main's chargeModule function who will trigger the code in my module.

- I externalise as well the RPC Call. So all my module got a pointer on my RPC project, and this one is collecting all the RPC client / server and shared code. It's usefull for deployment, enjoyable for developping to not recreate things already done etc... My servlet is put in my web.xml of my main by application route. Ex : /main/app1/greeting and this is pointed to my Implement class in my RPC project

- Common code, like connectLdap for example should so be placed in an other project (gwt module) called ExternalTools. This allow to use global class or function everywhere in my workspace.

- I create to finish a skeleton project who emulate my ldap login, using the RPC project and charge one module at once... so I can dev my module without using my main, but using the skeleton project, totally independently. Really useful for external development.


So my current project seems like : 
Main 
     |-- instanciate --> Menu (who get instance of main to launch chargeModule function with app and div argument)
     |-- instanciate --> App1 ----------- using --> RPC
     |-- instanciate --> App2 ----------- using --> RPC
     |                               |   
     |                   using if necessary  
     |                               |   
     |                              V
     |-- instanciate --> ExternalTools 

Skeleton (Using for dev)
     |-- instanciate --> App1 -- using --> RPC
     |                               |   
     |                   using if necessary  
     |                               |   
     |                              V  
     |-- instanciate --> ExternalTools 

For deployment, I have so only one .war, the only thing I have to do before uploading it on tomcat is to copy paste the class of my RPC project in my classes folder of my main's war. A easy bash is doing well the job.
So at the moment, all is working perfectly, my module loading and navigation is pretty fluid and clean and well separate. 

I given up on maven, who is complicating (in my opinion) all the works done. I gave a try to rest, but I found RPC easy enough at the moment for us, and it responsed well at our need ! 
If you have questions, observations or advices, I will be glad to read :)

PS : Sorry for my english, I wrote this post quickly and some terrible mistakes have should appears ! :D

--
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