Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Description of Template Files

Similarly, the The descriptions for both AppComponent and AppUiComponent remain the same as in the Custom View tutorial.

...

This class extends UiMessageHandler to implement code to handle that handles events from the (client-side) sample application view. Salient features to note:

...

Code Block
languagejava
@Override
protected Collection<RequestHandler> createRequestHandlers() {
    return ImmutableSet.of(
            new SampleDataRequestHandler(),
            new SampleDetailRequestHandler()
    );
}

 

(2) define SampleDataRequestHandler class to handle "sampleDataRequest" events from the client. Note that this class extends TableRequestHandler, which implements most of the functionality required to support the table data model:

Code Block
languagejava
private static final String SAMPLE_DATA_REQ = "sampleDataRequest";
private static final String SAMPLE_DATA_RESP = "sampleDataResponse";
private static final String SAMPLES = "samples";

... 
 
private final class SampleDataRequestHandler extends TableRequestHandler {
    private SampleDataRequestHandler() {
        super(SAMPLE_DATA_REQ, SAMPLE_DATA_RESP, SAMPLES);
    }
    ...
}

Note the call to the super-constructor, which takes three arguments:

  1. request event identifier
  2. response event identifier
  3. "root" tag for data in response payload

To simplify coding (on the client side) the following convention is used for naming these entities:

  • For a given table view, the table is identified by a "tag" (in this example, that tag is "sample")
    • request event identifier is derived: <tag> + "DataRequest"

    • response event identifier is derived: <tag> + "DataResponse"
    • "root" tag is derived <tag> + "s"

 

(2a) comment about defaultColumnId():

Code Block
languagejava
// if necessary, override defaultColumnId() -- if it isn't "id"

Typically, table rows have a unique value to identify the row (for example, in the Devices table it is the value of the Device.id() property). The default identifier for the column holding that value is "id". If you want to use a different column identifier for the unique row key, your class should override defaultColumnId(). For example:

Code Block
private static final String MAC = "mac";
 
...
 
@Override
protected String defaultColumnId() {
    return MAC;
}