Action: REFRESH

The action REFRESH refreshes the screen with fresh data. If the screen has a remote data source, then the remote data will be fetched first. Once the remote data is received, the local data is fetched. Now the controls are updated with the fresh data.

The action can be attached to the following elements <screen>, <control>

Attributes Value Mandatory
action_name REFRESH Yes
event_list comma separated list of events, eg: TAP Yes
target null or comma separated list of control names to be refreshed. No
remote_data_also true or false. Default is true No

Example 1

Below is the code snippet from the tutorial How to create a Simple list. The screen contains a reload button which has a REFRESH action attached to it. The “reload” button will refresh the screen by first fetching the remote data and then the local data.

<screens>
    <screen name="remotelist" screen_type="SCREEN" menuOrder="1" menuName="Remote" initial_layout="PORTRAIT" allowed_layouts="BOTH"
            width="100" height="100" tab_group_name="tabgroup1"
            remote_data_source="http://swimdash.com/swimdash/index/index/category/3/format/json"
            remote_request_type="GET" remote_data_save_locally="true">

        <title_controls>
                <control type="TEXT" x="0" y="1" width="100" height="6" default_value="Swim meets - remote datasource"
                         appearance_name="white" data_type="VARCHAR"/>
                <control name="reload" type="PUSHBUTTON" x="80" y="2" width="8.7" height="3.6"
                   appearance_name="black" data_type="VARCHAR" default_value="Reload">
                   <action name="REFRESH" event_list="TAP"/>
                </control>
                <control type="PROGRESSBAR" x="91" y="2" width="5.7" height="3.6" permission="READONLY"
                   appearance_name="black" data_type="VARCHAR" default_value="IMAGE:progressbar4.gif" />
        </title_controls>
        <controls>
            <control name="remotelist" type="LIST" x="0" y="0" width="100" height="100" permission="READONLY"
                   appearance_name="black" data_type="CURSOR"
                   local_data_source="SELECT sdid as _id, sdid, title, logo, (substr(start_date, 7,4) || '-' || substr(start_date, 1,2) || '-' ||  substr(start_date, 4,2) ) as start_date, (substr(end_date, 7,4) || '-' || substr(end_date, 1,2) || '-' ||  substr(end_date, 4,2) ) as end_date, meet_class  FROM featured order by start_date desc">
                   <!-- Child controls of list -->
                   <control type="IMAGE" x="1" y="1" width="12" height="10" permission="READONLY"
                   appearance_name="black" data_type="VARCHAR" field_name="logo" size="255"  />
                   <control type="TEXT" x="20" y="1" width="60" height="7" permission="READONLY"
                   appearance_name="black" data_type="VARCHAR" field_name="title" size="255" />
            </control>
         </controls>
    </screen>
</screens>

Example 2

In the example below, the screen has a reload button which has a REFRESH action attached to it. The “reload” button will refresh the screen with local data only (see the attribute remote_data_also=”false”).

<screens>
    <screen name="remotelist" screen_type="SCREEN" menuOrder="1" menuName="Remote" initial_layout="PORTRAIT" allowed_layouts="BOTH"
            width="100" height="100" tab_group_name="tabgroup1">

        <title_controls>
                <control type="TEXT" x="0" y="1" width="100" height="6" default_value="Swim meets - remote datasource"
                         appearance_name="white" data_type="VARCHAR"/>
                <control name="reload" type="PUSHBUTTON" x="80" y="2" width="8.7" height="3.6"
                   appearance_name="black" data_type="VARCHAR" default_value="Reload">
                   <action name="REFRESH" event_list="TAP" remote_data_also="false"/>
                </control>
                <control type="PROGRESSBAR" x="91" y="2" width="5.7" height="3.6" permission="READONLY"
                   appearance_name="black" data_type="VARCHAR" default_value="IMAGE:progressbar4.gif" />
        </title_controls>
        <controls>
            <control name="remotelist" type="LIST" x="0" y="0" width="100" height="100" permission="READONLY"
                   appearance_name="black" data_type="CURSOR"
                   local_data_source="SELECT sdid as _id, sdid, title, logo, (substr(start_date, 7,4) || '-' || substr(start_date, 1,2) || '-' ||  substr(start_date, 4,2) ) as start_date, (substr(end_date, 7,4) || '-' || substr(end_date, 1,2) || '-' ||  substr(end_date, 4,2) ) as end_date, meet_class  FROM featured order by start_date desc">
                   <!-- Child controls of list -->
                   <control type="IMAGE" x="1" y="1" width="12" height="10" permission="READONLY"
                   appearance_name="black" data_type="VARCHAR" field_name="logo" size="255"  />
                   <control type="TEXT" x="20" y="1" width="60" height="7" permission="READONLY"
                   appearance_name="black" data_type="VARCHAR" field_name="title" size="255" />
            </control>
         </controls>
    </screen>
</screens>