Specifications and Views in Remote Phlow

This page looks at how Views and Specifications work in Remote Phlow. It uses a List view as an example.

The data for creating a view is modeled using a GtPhlowViewSpecification Object subclass: #GtPhlowViewSpecification instanceVariableNames: 'phlowDataSource methodSelector title priority dataTransport' classVariableNames: '' package: 'GToolkit-RemotePhlow-DeclarativeViews' instance. The specification is initialized with a phlow data source responsible with accessing data from the view.

For list views, the specification is GtPhlowListViewSpecification GtPhlowListingViewSpecification subclass: #GtPhlowListViewSpecification instanceVariableNames: '' classVariableNames: '' package: 'GToolkit-RemotePhlow-DeclarativeViews' .

Getting informations about views

We use an instance of the object GtRemotePhlowDeclarativeTestInspectable Object subclass: #GtRemotePhlowDeclarativeTestInspectable instanceVariableNames: 'string collectionOfObjects' classVariableNames: '' package: 'GToolkit-RemotePhlow-Examples' as an example

targetObject := GtRemotePhlowDeclarativeTestInspectable new
  

Next we create an inspector wrapper for the object. This object knows how to extract view information from the object

inspectorWrapper := GtRemotePhlowViewedObject object: targetObject
  

Inspect the raw data about an objects's views. Here we get the name of the methods defining views and the raw data for creating view specifications.

inspectorWrapper getDeclarativeViewMethodNames
  
inspectorWrapper getViewsDeclarations
  

We can inspect the wrapper object to see what has been initialized.

inspectorWrapper
  

Directly accesing the view specification

We can get the view specification object for a view directly from the inspector wrapper. For List views will be an instance of GtPhlowListViewSpecification GtPhlowListingViewSpecification subclass: #GtPhlowListViewSpecification instanceVariableNames: '' classVariableNames: '' package: 'GToolkit-RemotePhlow-DeclarativeViews' , or a proxy in case the inspector wrapper is itself a proxy.

viewSpecification := inspectorWrapper 
	getDeclarativeViewFor: #gtListFor:
  

Here we get the content of the view directly from the view specification.

viewSpecification 
	retrieveItems: 1 
	fromIndex: 2
  

As an example we can also get all the items or the number of items

viewSpecification retriveFormattedItems
  
viewSpecification totalItemsCount
  
viewSpecification retriveSentItemAt: 1
  

Constructing the view specification locally

What the inspector does when needing to show a list view is to get the data of the view specification from the inspector wrapper, create a new instance of the specification locally, and link it with the remote datasouce for that view.

First we get the data

viewSpecificationData := inspectorWrapper getViewDeclaration: #gtListFor:
  

And then we instantiate and configure the view specification.

localViewSpecification := GtPhlowViewSpecification 
	fromDictionary: viewSpecificationData.
localViewSpecification initializeFromInspector: inspectorWrapper.
  

We can now use the same methods as before to access the list items.

In this case we make the call to the local view specification, that delegates the call to the remove datasource, that knows how to get the items from the remove view.

localViewSpecification 
	retrieveItems: 2 
	fromIndex: 2
  
localViewSpecification retriveFormattedItems
  
localViewSpecification totalItemsCount
  
localViewSpecification retriveSentItemAt: 1
  

Using a simulation

We can also simulate how this object is inspected remotely.

GtRemoteInspectionSimulation openOn: targetObject