Skip to content
Kristian Meier edited this page Oct 16, 2011 · 4 revisions
  • menu: adds a menu bar - one entry for each scaffolded model
  • session: adds a login session to the application
  • remote-user (pending): clones a simple list of users from remote for modified-by models

basic directory layout

first the rails part is just standard rails with

  • one extra directory in ./public/WEB-INF - the jetty setup to run rails for GWT development shell
  • the java sources in ./src
  • ./target the working directory for the build system. this will also include the project specific rubygems repository in ./target/rubygems.
.
├── app
├── config
├── db
├── doc
├── lib
├── log
├── public
│   ├── images
│   ├── javascripts
│   ├── stylesheets
│   └── WEB-INF
├── script
├── src
├── target
├── test
├── tmp
└── vendor

the ./target can beput in .gitignore since it is of temporary nature. the rubygems will be installed (via bundle) whenever you use rmvn or gwt or jetty-run commands.

new rails application without given options

to setup resty you need to choose a direcotry and a java package name where to locate the GWT code (like com.example)

gwt new my_app com.example

with this you have already a GWT application with EntryPoint and could be started but does not do much. the class layout in my_app directory:

src/main/java/com/example/client/
├── ActivityPlaceActivityMapper.java
├── ActivityPlace.java
├── managed
│   ├── ActivityFactory.java
│   ├── MyAppModule.java
│   └── MyAppPlaceHistoryMapper.java
└── MyAppEntryPoint.java

the classes in the client package can be adjusted at will and the classes in the client/managed package are the plug points to add new resources (models) to the application. these classes will be modified by the scaffold generator from rails. so caution is needed to edit these files.

new rails application with menu options

have a look at how the menu gets hooked into the GWT and if that fits your needs.

gwt new my_app com.example --menu

the class layout in my_app directory:

src/main/java/com/example/client/
├── ActivityPlaceActivityMapper.java
├── ActivityPlace.java
├── managed
│   ├── ActivityFactory.java
│   ├── MyAppMenuPanel.java
│   ├── MyAppModule.java
│   └── MyAppPlaceHistoryMapper.java
└── MyAppEntryPoint.java

there is basically only one more class popping up MyAppMenuPanel in comparision to a new application without any options.

new rails application with session options

this is a bit invasiv, so have a look and see if it fits and suits your needs.

gwt new my_app com.example --session

the class layout in my_app directory:

src/main/java/com/example/client/
├── activities
│   └── LoginActivity.java
├── ActivityPlaceActivityMapper.java
├── ActivityPlace.java
├── BreadCrumbsPanel.java
├── managed
│   ├── ActivityFactory.java
│   ├── MyAppModule.java
│   └── MyAppPlaceHistoryMapper.java
├── models
│   └── User.java
├── MyAppEntryPoint.java
├── places
│   └── LoginPlace.java
├── restservices
│   └── SessionRestService.java
├── SessionActivityPlaceActivityMapper.java
└── views
    ├── LoginViewImpl.java
    └── LoginView.ui.xml

this comes with a bunch of view related packages/classes.

  • first there is the login place with its views and activity
  • the SessionRestfulService which uses the User class to authenticate
  • the BreadCrumbsPanel with a logout button
  • the SessionActivityPlaceActivityMapper which ensures the a valid client session object. if session is not active then a login activity will be triggered.
  • the default idle session timeout is 15 minutes and can be configured in config/application.rb by adding config.idle_session_timeout = 30 # minutes

the login is hardcoded:

  • username can be choosen
  • password is behappy
  • the groups of the logged in user is the username itself

with this username root will give you full access.

when using [remote-authentication](remote authentication) situation is different.

new rails application with session and menu options

this is a bit invasiv, so have a look and see if it fits and suits your needs.

gwt new my_app com.example --session --menu

the class layout in my_app directory:

src/main/java/com/example/client/
├── activities
│   └── LoginActivity.java
├── ActivityPlaceActivityMapper.java
├── ActivityPlace.java
├── BreadCrumbsPanel.java
├── managed
│   ├── ActivityFactory.java
│   ├── MyAppMenuPanel.java
│   ├── MyAppModule.java
│   └── MyAppPlaceHistoryMapper.java
├── models
│   └── User.java
├── MyAppEntryPoint.java
├── places
│   └── LoginPlace.java
├── restservices
│   └── SessionRestService.java
├── SessionActivityPlaceActivityMapper.java
└── views
    ├── LoginViewImpl.java
    └── LoginView.ui.xml

this is bascially the same as before plus the MyAppMenuPanel

Clone this wiki locally