Creating different frontends in one application

73 views
Skip to first unread message

Bestmacfly

unread,
Mar 4, 2012, 6:14:26 AM3/4/12
to Google Web Toolkit
Dear all,
I'm creating a booking system using GWT. The backend is nearly
completed. I have created one html page with one entry point, in my
entry point I'm changing navigation / layout of the page dynamically.
Now I need a second frontend, which will be totaly different from the
already created backend. This second frontend should be able to use
the whole code stuff from my backend (especialy the Requestfactory
proxies). As far as I understood, it is not possible to simple create
a second entry point in my application and combine this second entry
point with a second base html page. So what would be the best approach
now to realize this?

Best regards

Mark

Olivier

unread,
Mar 4, 2012, 6:26:37 AM3/4/12
to Google Web Toolkit
Hi Mark,

Maybe one way of doing this is to add a parameter in the URL for your
clients. Just one example

--> For the first type of users, you ask them to access your site at
http://www.yoursite.com?destination=site1

--> For the second type of users, you ask them to access your site at
http://www.yoursite.com?destination=site2

In your entry point module, you redirect to a different class
according to the parameter. This is the code that should do the
trick :

String destination = Window.Location.getParameter("destination");

if (destination.equals("site1") then {
display_web_site1()
}
if (destination.equals("site2") then {
display_web_site2()
}

There might be (better) ways of doing this but this one should work.

Cheers,

Olivier

Eng. Ahmed Youssef

unread,
Mar 4, 2012, 7:02:58 AM3/4/12
to google-we...@googlegroups.com
Actually, It is simple.

On the GWT side, you can duplicate the ".gwt.xml" file and change the name and stuff... both modules will be recognized and will be separate and can share all the code. Of course you will need to name them differently. And create a second html file that points to the second module files. When compiled you will have two different sets of files in two different folders.

On the backend, you can re-use the code as you wish and make two different servlets or whatever, it should be easy enough to do.

Thomas Broyer

unread,
Mar 4, 2012, 2:06:08 PM3/4/12
to google-we...@googlegroups.com
The great thing with RequestFactory (compared to GWT-RPC), is that your client(s) is not tightly bound to your server. Simply create another "GWT app" (another *.gwt.xml, either in the same Eclipse project or in a distinct one, as you prefer; called from another HTML page) and use your RequestFactory interfaces; it should Just Work™. You can deploy both GWT (client-side) apps in the same WAR (i.e. along with a shared server-side implementation).

Bestmacfly

unread,
Mar 10, 2012, 8:10:43 AM3/10/12
to Google Web Toolkit
Hi all,
thank you very much, it works for me now as you described:

I have created a new module inside my existing project. The new xml is
placed in the same folder as the xml of my first project. I created a
new client package for the second frontend and a corresponding html-
page for the second xml.

One advice for others with the same problem:

I wanted to use RPC-services of my first module in my second module.
To do so, you have to move the client-RPC-classes to share (else your
second module will not find the needed classes). In addition, the
web.xml-pathes for the RPC Servlets have to be adjusted, e.g.:
<servlet-mapping>
<servlet-name>loginServiceImpl</servlet-name>
<url-pattern>/module1/loginService</url-pattern>
</servlet-mapping>

<servlet-mapping>
<servlet-name>loginServiceImpl</servlet-name>
<url-pattern>/module2/loginService</url-pattern>
</servlet-mapping>

I'm pretty sure that one servlet mapping with a wildcard-path should
also work.

Best regards

Mark

Joseph Lust

unread,
Mar 13, 2012, 8:37:33 PM3/13/12
to google-we...@googlegroups.com
While I am a fan of the decoupling pointed out by Thomas Broyer with RequestFactory, you can still do the same thing with RPC rather easily, and skip the need for RequestFactory.

In the projects at my office, we use Maven and the following project structure:
  • MainProject.pom
    • Client-Interfaces.pom
    • Client-GWT.pom (uses Interfaces)
    • Server.pom (uses Interfaces)
    • Web.pom 
So just running the main pom will build the interfaces that are then used by the server side code and the client side GWT. The Web project contains Tomcat specific items and dictates how the war is packed up.

Perhaps this will work for you Mark and you can just have two client side GWT packages.

Sincerely,
Joseph
Reply all
Reply to author
Forward
0 new messages