# Binding data model context

<span class="notranslate">To easiest the readability and maintainability of the code, and to shorten in XPath paths, some components can works as a relative xpath context for the contained ZK components.</span> <span class="notranslate">When a container type object is associated with a data model element, binds on child components that do not specify a data source are understood as parent container relative XPaths.</span>

<span class="notranslate">The components that can act as context data model implement the es.caib.zkib.BindContext interface.</span> <span class="notranslate">Currently, grid, lisbox, row and form components.</span> Due to implementation<span class="notranslate"> constraints, the listiem object does not implement the aforementioned interface.</span>

<span class="notranslate">The simplest of those components is the Form object (which derives from Vbox).</span> <span class="notranslate">For context associations, the attribute to be used is called datapath, as shown in the following example:</span>

```western
<?xml version = "1.0" encoding = "UTF-8">
<zk>
    <xmlDataSource id = "mydata" src = "/ my-data.xml" />
    <form dataPath = "/mydata:/title">
        <label bind = "/@name" />
        <textbox bind = "/@name" />
        <button label = "Update" />
     </form>
</zk>
```

In this example, both the object label, as the textbox object refer to the same attribute @name, which is relative to the context /mydate:/title. When the user changes the textboxitem, the same text will be shown on the label. Mind the synchronization will only be done when the data is sent to the server, by means of any ZK event. In order to make user interface to be more responsive, simply add an onChange or onChanging null handler to the textbox component.

```XML
<?xml version = "1.0" encoding = "UTF-8">
<zk>
    <xmlDataSource id = "mydata" src = "/ my-data.xml" />
    <form dataPath = "/mydata:/title">
        <label bind = "/@name" />
        <textbox bind = "/@name" onChanging=""/>
        <button label = "Update" />
     </form>
</zk>
```