Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.maryanovsky.gwtutils.client
Class Application

    java.lang.Object
      com.maryanovsky.gwtutils.client.Application

All Implemented Interfaces:
  EntryPoint

    public abstract class Application

extends Object
implements EntryPoint

A class which handles much of the heavy lifting of starting up an application. The class handles the following:

- Parses the URL parameters of the page's URL and puts them in `URL_ARGS`
- Sets the `SETTINGS_URL` field to the URL of the application settings. By default this is simply "settings.properties", but it can also be specified by a URL parameter named "settingsUrl".
- Enables or disables window scrolling based on the value returned by `isWindowScrollingEnabled()`, which can be overridden.
- Sets an uncaught exception handler to the value returned by `getUncaughtExceptionHandler()`, which can be overridden.
- Makes the requests required to start the application. These are specified by `getApplicationStartRequests()` which can be overridden.
- Once all the requests required to start the application have finished, invokes `startApplication()`, which should be overridden
.

Author:
  Maryanovsky Alexander

Nested Class Summary
`static class` | `Application.RequestMakerResponseHandlerPair`

Field Summary
`protected String` | `SETTINGS_URL` The URL of the settings file.
`protected ResultCallback<String>` | `settingsResponseCallback` The `ResultCallback` for the settings request.
`protected static Map<String,String>` | `URL_ARGS` The arguments passed to us via the URL.

Constructor Summary
`Application()`

Method Summary
`protected RequestMaker<String>` | `createSettingsRequestMaker()` Creates the request maker for the settings file.
`protected List<Application.RequestMakerResponseHandlerPair>` | `getApplicationStartRequests()` Returns the list of requests that need to be made for the application to start and their handlers.
`protected String` | `getSettingsUrl()` Returns the URL of the settings file.
`protected GWT.UncaughtExceptionHandler` | `getUncaughtExceptionHandler()` Returns the uncaught exception handler for the application.
`protected boolean` | `isWindowScrollingEnabled()` Returns whether window scrolling should be enabled for the application.
`protected void` | `onErrorMakingRequest(String url, String errorMessage)` Invoked when making one of the requests required to start the application fails (that is, `RequestBuilder.sendRequest(String, RequestCallback)` threw a `RequestException`).
`protected void` | `onErrorRetrievingSettings(String settingsUrl, String errorMessage)` This method is called when an error occurs while retrieving the application settings.
`protected void` | `onInvalidSettings(String errorMessage)` Invoked when the settings are invalid.
`void` | `onModuleLoad()` The entry point method.
`protected abstract void` | `onSettingsReceived(String settingsText)` Invoked when the settings are received.
`protected void` | `showError(String errorMessage)` Displays the specified error message to the user.
`protected abstract void` | `startApplication()` Starts the application.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### URL_ARGS

    protected static final Map<String,String> URL_ARGS

  The arguments passed to us via the URL.

### SETTINGS_URL

    protected final String SETTINGS_URL

  The URL of the settings file.

### settingsResponseCallback

    protected final ResultCallback<String> settingsResponseCallback

  The `ResultCallback` for the settings request.

Constructor Detail

### Application

    public Application()

Method Detail

### onModuleLoad

    public void onModuleLoad()

  The entry point method.

  Specified by:
    `onModuleLoad` in interface `EntryPoint`

### getSettingsUrl

    protected String getSettingsUrl()

  Returns the URL of the settings file.

### getApplicationStartRequests

    protected List<Application.RequestMakerResponseHandlerPair> getApplicationStartRequests()

  Returns the list of requests that need to be made for the application to start and their handlers. The default implementation returns a list with a single item - the pair `(`createSettingsRequestMaker()`, `settingsResponseCallback`)`. If your application needs to retrieve more information in order to start, you should override this method and return additional request builders (and corresponding callbacks).

### createSettingsRequestMaker

    protected RequestMaker<String> createSettingsRequestMaker()

  Creates the request maker for the settings file.

### isWindowScrollingEnabled

    protected boolean isWindowScrollingEnabled()

  Returns whether window scrolling should be enabled for the application. Note that this method is called from `onModuleLoad()`. The default implementation returns false.

### getUncaughtExceptionHandler

    protected GWT.UncaughtExceptionHandler getUncaughtExceptionHandler()

  Returns the uncaught exception handler for the application. Note that this method is called from `onModuleLoad()`. The default implementation returns an exception handler which shows an (unlocalized) alert describing the exception that occurred.

### onErrorMakingRequest

    protected void onErrorMakingRequest(String url,
                                        String errorMessage)

  Invoked when making one of the requests required to start the application fails (that is, `RequestBuilder.sendRequest(String, RequestCallback)` threw a `RequestException`). The default implementation displays an (unlocalized) alert describing the error that occurred.

### onErrorRetrievingSettings

    protected void onErrorRetrievingSettings(String settingsUrl,
                                             String errorMessage)

  This method is called when an error occurs while retrieving the application settings. The default implementation shows an (unlocalized) alert describing the error.

### onSettingsReceived

    protected abstract void onSettingsReceived(String settingsText)
                                        throws ParseException

  Invoked when the settings are received. The method is meant to parse the settings, and store them in a field until `startApplication()` is invoked (where they will be used).

  Throws:
    `ParseException`

### onInvalidSettings

    protected void onInvalidSettings(String errorMessage)

  Invoked when the settings are invalid. The default implementation shows an (unlocalized) alert describing the error.

### showError

    protected void showError(String errorMessage)

  Displays the specified error message to the user. This is not an error that occurs normally. The default implementation shows it in an alert.

### startApplication

    protected abstract void startApplication()

  Starts the application. This method is invoked when all the requests required to start the application have finished. Note that this happens even if some of them failed - it is up to you, when overriding this method, to check whether you have all the information you need.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD