Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GWT multi modules for separate HTML pages?

I am quite new to GWT and going to develop the UI for user-management application using GWT. I am planning to use existing module which created using Spring/Hibernate. I figured out how to integrate GWT with Spring but I am not sure how to design the layout.

I want two pages:

  1. User registration page (want to embedd GWT widget in HTML)
  2. Administration page (seperate HTML as above with GWT widget embedded)
  3. I am planing to use Spring Security,shall I use simple JSP login page or can I use RIA GWT login widget?

What can I use for above requirements? multiple GWT modules?

like image 565
Ashika Umanga Umagiliya Avatar asked Dec 14 '09 02:12

Ashika Umanga Umagiliya


2 Answers

You could make 2 modules, one for the login widget, and another for the admin widget. Each widget will insert itself into a div in whichever html (or jsp) page you want.

For example, create a *.gwt.xml for each module, for example: login.gwt.xml and admin.gwt.xml. These files should both be created at the root of your gwt package, for example: com.gwt.example.

Next, create an "Entry Point" class for each (each class will implement EntryPoint). For example, Login.java might look like:

package com.gwt.example.myproject.client;

public class Login implements EntryPoint {

  public void onModuleLoad() {
    ... create loginWidget ..

    RootPanel.get("my-login-div").add(loginWidget);

  }

}

So, now, when you do a gwt compile, it should create a bunch of files under war/com.gwt.example. The two you're interested in are com.gwt.example.login.nocache.js and com.gwt.example.admin.nocache.js.

Now, you can add these two js scripts into any html and/or jsp page as needed.

To complete the example, you could add the following html to add the login widget:

<html>
....other stuff...
<script type="text/javascript" language="javascript" src="com.gwt.example.login.nocache.js"></script>
....other stuff....
<div id="my-login-widget"></div>
....the rest of your html markup....
</html>

So, when you browse to this html page, it loads compiled gwt javascript, which knows to load onModuleLoad, which looks for div with id="my-login-widget" and inserts the login widget.

I've never used Spring Security, so can't be much help, other than this article looks like it might describe how to make Spring Security work over ajax.

like image 126
Upgradingdave Avatar answered Nov 11 '22 06:11

Upgradingdave


You can create two modules or use only one.

I recently created an application where there was only one page, and the login panel was shown first, like an inner dialog box. When the session expired, the user was prompted to enter his credentials again. But I was going for a 100% no-page-refresh approach. It is nice, but the disadvantage is that the browser will have to download everything upfront. Well… at least until GWT 2.0.

like image 1
ciczan Avatar answered Nov 11 '22 07:11

ciczan