More advanced applications will likely want to add functionality by performing specific actions in response to user input. There are a few methods provided in MapBuilder to customize your application.
An important aspect of the MVC design pattern is that it is event driven. Almost everything that happens over the course of the application execution is the result of an event being triggered on a model, which then calls listener functions registered with that model. This allows the models, widgets and tools to remain independant of each other and makes MapBuilder very modular - objects can be added and removed from the configuration without affecting the other objects.
There is a global "config" object that can be referenced from anywhere. You can retrieve a reference to all other objects by using the config.objects property. For example, a model with an ID of "model_x" would be referenced as config.objects.model_x, or config.objects["model_x"].
The following functions are available for carrying out user actions:
This method will load the model with the specified modelId from the docUrl provided. This will also trigger a "loadModel" event for that model.
Updates the value of a node in the model's XML document and optionally triggers a "refresh" event for this model (based on the boolean refresh argument value). The xml node to be updated is specified by the xpath argument.
button action property
Buttons in the configuration file accept an <action> property which specifies an object method to be called when a button is selected.
The way to use these functions is to set them as the HREF element of an anchor tag:
or as an event handler (onclick, onmouseover, etc.) on any HTML element that allows it:
called just before a Model document is loaded
called after a Model document is successfuilly loaded
called to indicate that widgets should repaint themselves. The optional "widgetId" argument indicates that only the widget with that ID should be refreshed.
called whenever the state of the model has changed. The optional status message string describes the change in state; if it is null it indicates that the message should be cleared.
called before the prepaint method of a widget based on WidgetBaseXSL is executed.
called after the postpaint method of a widget based on WidgetBaseXSL is executed.
called whenever GmlRendererOL creates or destroys its vector layer.