How to use an existing data handler
You can use a data handler to display a certain set of results retrieved through the web service.
Identify handler in page.config
If we plan to use a data handler, the handler should be identified in the page config.
The below code adds the ProjectEntityDataHandler
to the Contact page.
<page id="ContactPage">
<data>
<datahandlers>
<!-- Some other Data Handler declarations-->
<!-- Our Data Handler-->
<datahandler id="ProjectEntityDataHandler" type="ProjectEntityDataHandler"></datahandler>
<!--End of our Data Handler-->
</datahandlers>
</data>
<!-- Some other code-->
</page>
The handler can now be used and identified by the datahandler ID.
Use handler in panel
The following code segment shows the use of the above data handler in the SoContactPanel.config file.
<?xml version="1.0" encoding="utf-8"?>
<panel id="Contact" type="SplitterPanel" soprotocol="Contact" paneltype="Main" placeholderid="MainPlaceHolder">
<caption>[SR_COMMON_CONTACT]: [current:contact_name]</caption>
<cards>
<card id="ContactMainCard" type="SoTabbedCard" placeholderid="leftpanel" cardtype="MainCard">
<views>
<!-- Some other code-->
<view id="more" type="SoView" soprotocol="udef" current="contact">
<caption>[SR_MORE_CONTACT]</caption>
<tooltip>More...</tooltip>
<controlgroups>
<!-- Some other code-->
<!-- Our Data Handler-->
<controlgroup id="ProjectMainGroup" type="SoControlGroup" left="500px" position="absolute" right="50px" top="25px">
<controls>
<control id="newLabel" type="SoLabel" context-style="Heading" row="0" column="0">
<caption>Projects</caption>
</control>
<control id="ProjectNameOnContact" type="SoTextBox" width="100%">
<datasource>ProjectEntityDataHandler.ProjectEntity.Name</datasource>
</control>
</controls>
</controlgroup>
<!--End of our Data Handler-->
</controlgroups>
<!-- Some other code-->
</view>
<!-- Some other code-->
</views>
<!-- Some other code-->
</card>
<!-- Some other code-->
</cards>
<!-- Some other code-->
</panel>
Here we have used ProjectEntityDataHandler
to call the project name from the web service. The following line retrieves the project name by accessing the Project entity’s name
property.
<datasource>ProjectEntityDataHandler.ProjectEntity.Name</datasource>
Since we plan to display the results in a text box in the control tab, we declared it as giving the type type=SoTextBox
.
The Contact page’s More view after the modification: