App Config
Before learning about app config...
Check out the Key Concepts.
While layouts depict the visual structure of how components are going to appear in the viewer, app config is used to define the functional structure within a given component.
Think of the app config as the structural materials for building a house (wood, bricks, etc.) and the layout as the blueprints for the house.
The materials are the fundamental building blocks that create the house itself, and the blueprints allow for them to be structured together into something that people can interact with.
Every component within the viewer that requires functional, compositional content needs to be configured within the viewer's corresponding app config.
Want to follow along?
Check out the Quickstart and edit the default app config and layout.
Anatomy of an App config
An app config file is composed of a list of app items. App items can potentially be anything. Each app item has an item $type
, which viewer is aware of and knows how to locate and load. They usually they represent configuration for components, maps, portal items, or shared data. All item app configuration is specified within the items
array of the app.json
file.
note
Each component can only load a certain $type
of app item which corresponds to it. For example, <map>
components can only load app items of type map-extension
as their configuration.
Linking Layout to App Config
Every component in the layout can be linked to app config with the config
attribute. The config
attribute is used to identify the item in the app config that has configuration for the component.
note
If you do not provide a config
attribute for a component, Geocortex Mobile will attempt to infer a default value.
- Layout
- App Config
Targeting Components by ID
Every component can also have an id
attribute. The id
attribute uniquely identifies a component within a layout and allows app items to target the component. The ID can be used by commands like ui.activate
to target components, or by commands like run.workflow
to target a host container component to display workflow UI within.
- Layout
- App Config
- User Interface
note
This example uses commands and operations to power its behavior.
Example: Basic App Config with IWTM
The I Want To Menu (IWTM) gets its functional structure from the app (list items and their functionalities) and its visual structure from the layout.
In the following example, the app structures a menu with one button, and the layout creates the IWTM button in the viewer and populates its contents with the corresponding 'menu' item in the app.
- App Config
- Layout
- User Interface
The <iwtm>
Component in the layout is bound to the IWTM configuration by the attribute config="iwtm"
, where iwtm
corresponds to the ID of the IWTM configuration. All components can be bound to config in this manner, and multiple components can be bound to the same configuration.
Each app item has a different $type
and different configurable properties associated with it. The example application has two items in the app config:
- A layout
$type
item which serves as a default layout and references alayout-*.xml
file - A menu
$type
item which provides config for the I Want To Menu in the layout
important
The functionality of the config
attribute is dependent on the fact that IDs across app items of the same type are unique. That is, two items of types layer-extension
and map-extension
can both have the ID default
, but two items of the same type layer-extension
cannot have the same ID default
.
Relevant SDK Samples
The Geocortex Mobile SDK Samples project has a variety of app configuration samples:
Next Steps: Commands and Operations
This example demonstrated a simple application which has a single menu, but the pattern of loosely coupling layout components with items in app config can allow you to build powerful apps with multiple layouts for different form factors and use cases. What we didn't cover in this example was how the menu items are powered. How can we make a menu item, and more generically, a button press or other app interaction, power actions in the application? The answer is to link app items to commands and operations.
Commands and Operations
Learn about Commands and Operations and how to configure them.
App Config Reference
Learn more about what you can accomplish with app config.