Data - AppDaddy-Software-Solutions-Inc/framework-markup-language GitHub Wiki

DATA : DataSource

The <DATA/> datasource widget can be used standalone to store static data. It can also be linked to another datasource element directly by specifying the source datasource by is id in its value attribute or indirectly by nested it inside of another datasource. When its parent's data (if specified) changes, that data is fed to the <DATA/> datasource automatically and transformed and aggregated accordingly.

The <DATA/> datasource widget is used to extract a set or subset of data from its parent datasource and transform that data through the use of the <TRANSFORM/> widget. Data can also be aggregated based on the type attribute.

Attributes

Name Type Default Description Req
value JSON, XML or ID.data binding null The value of the widget. Is automatically assigned as the parents value if a child of another Datasource
type string null replace, lifo, fifo, append, prepend. Defines the data aggregation strategy for data returned from initial and subsequent calls. replace (default) replaces all data after each subsequent call. lifo (last in first out), fifo (first in first out), append and prepend are all used in conjunction with the maxrecords attribute
maxrecords int 10000 The maximum number of data rows
root string transparent The root tag that the broker will look in data returned. This can be a nested field
ttl int(s,m,h) 0s Time to Live caches data in the local persistent HIVE database for the period specified. This saves having to re-query data that changes infrequently
tti int(s,m,h) 5s The time the Datasources status will stay as anything but idle.
onsuccess string/Event null The string of events the broker will execute upon a successful query.

Events

Name Type Description
clear() Clears the databroker. Invoked in any EVENT string using <id>.clear()
add(value, index) Adds a value to the datasource. Invoked in any EVENT string using <id>.clear()
remove(index) Removes a value form the datasource. Invoked in any EVENT string using <id>.clear()

Properties

Name Type Default Description Req
rowcount int 0 The number of records in the data bindable
status string idle The status of the broker, returns error, success or idle.
statusmessage string null Returns a status message (usually from the response on an exception ).
statuscode string null Returns the http status code.
httpstatus string null Returns the generic message associated with the http status code.

Examples

Example #1

The following snippet demonstrates a static DATA element used to store information for use in the SELECT element.

<FML title="Isaac test">
<COLUMN>    
    <DATA id="MONTHS" root="SET.MONTH">
        <VALUE>
        <![CDATA[
        <SET>
            <MONTH>
                <monthno>1</monthno>
                <month>January</month>
            </MONTH>
            <MONTH>
                <monthno>2</monthno>
                <month>February</month>
            </MONTH>
            <MONTH>
                <monthno>3</monthno>
                <month>March</month>
            </MONTH>
            <MONTH>
                <monthno>4</monthno>
                <month>April</month>
            </MONTH>
            <MONTH>
                <monthno>5</monthno>
                <month>May</month>
            </MONTH>
            <MONTH>
                <monthno>6</monthno>
                <month>June</month>
            </MONTH>
            <MONTH>
                <monthno>7</monthno>
                <month>July</month>
            </MONTH>
            <MONTH>
                <monthno>8</monthno>
                <month>August</month>
            </MONTH>
            <MONTH>
                <monthno>9</monthno>
                <month>September</month>
            </MONTH>
            <MONTH>
                <monthno>10</monthno>
                <month>October</month>
            </MONTH>
            <MONTH>
                <monthno>11</monthno>
                <month>November</month>
            </MONTH>
            <MONTH>
                <monthno>12</monthno>
                <month>December</month>
            </MONTH>
        </SET>
        ]]>
        </VALUE>
    </DATA>
    
    <SELECT id="S1" data="MONTHS">
      <OPTION value="{data.monthno}" label="{data.month}"/>
    </SELECT>
    
    <TEXT label="Month 1 in datasource MONTHS is {MONTHS.data:0.month}" />
    <TEXT label="Month 2 in datasource MONTHS is {MONTHS.data:1.month}" />
</COLUMN>

logo See it in Action

Example #2

This DATA Datasource accesses the nested TEMPLATE root inside of the SELECT's chosen option. The individual rows nested within the selects option are then filtered.

<GET id="OEE2GET" url="http://someurl.com" autoexecute="true">
        <HEADER/>

        <DATA id="OEE2GET_CATEGORY_SCHEDULED_TIME">
            <FILTER filter="'{data.OEE_CATEGORY}' == 'Scheduled Time'" />
        </DATA>

        <DATA id="OEE2GET_CATEGORY_AVAILABLE_TIME">
            <FILTER filter="'{data.OEE_CATEGORY}' == 'Available Time ( as % of 100% )'" />
        </DATA>
        
        <DATA id="OEE2GET_CATEGORY_OPERATING_TIME">
            <FILTER filter="'{data.OEE_CATEGORY}' == 'Operating Time ( as % of 100% )'" />
        </DATA>
        
        <DATA id="OEE2GET_CATEGORY_EFFECTIVE_TIME">
            <FILTER filter="'{data.OEE_CATEGORY}' == 'Effective Time ( OEE1 )'" />
        </DATA>
    </GET>
```

### Example #3

This DATA Datasource accesses the nested element once a select option has been chosen.

````xml
     <DATA id="userjetdata" value="{userselect.data}" root="jets"/>

     <TYPEAHEAD id="userselect" data="userdata" hint="Search by name, tail number, or icao" onchange="trackerdata.start();aircraftinfo.start();">
         <OPTION value="{data.firstName} {data.lastName}"/>
     </TYPEAHEAD>

     <SELECT data="userjetdata" hint="Select a Jet" addempty="false" onchange="trackerdata.start();aircraftinfo.start();">
	 <OPTION value="{data.tailNumber}"/>
     </SELECT>
```
⚠️ **GitHub.com Fallback** ⚠️