Skip to end of metadata
Go to start of metadata

Template Models

A model template is one where you can specify a pattern for all instances of that model in the config file, but the template object itself will likely never get populated with a document. New instances of the Model object get created by a tool and each new instance will be created as specified by the template, much as if was coded into the config file in the first place. (In fact, the runtime config file could be saved to disk and reloaded.) Since each new instance of the template requires a new HTTP request, the tool takes responsibilty for preparing the HTTP payload object (URL/method/postData). The tool can target a particular template using the "targetModel" property. Creating the model objects and appending them to the config doc is handled in the newRequest() method of ModelBase.

An example of a config file with a template model (much simplified for clarity):

this specifies a FeatureCollection model that has one GmlRendererWZ widget. However, because the Model has the template attribute set to true, it is considered as a template. If the template attribute was false or missing, the tool would just populate that Model object with a document.

The the user can interact with the web page, perhaps adding FeatureCollections by clicking and editing points on the map, or by selecting and loading GetFeature requests to a WFS as a result of a search for FeatureTypes. These actions will trigger the tool to generate the web service requests. So at runtime, the config file could look like:

The WebServiceRequest tool is an example of a tool that is used to generate an HTTP payload. This tool takes a node from it's model (e.g. WMS Layer or WFS FeatureType nodes from capabilities documents) and generates the URL query parameters or body of POST request by applying a stylesheet to that node. Other types of tools to generate HTTP requests could be envisaged (e.g. SOAP request tool driven by a WSDL document). More details on using this tool are in the tutorial Using the WebServiceRequest tool.

  • No labels