We set breakpoint on this line which is already discussed in previous blog.
For the logic how the variable oMetaData.annotations.uom is parsed from metadata.xml, please refer to previous blog.
In OData Metadata, we use the following annotation to tell Framework that the UI element which is bound to "CurrencyCode" field in the model must be rendered as value list.
And the Target property is parsed in the runtime:
The calculated annotation from line 495 above is used to enable the original currency field with value help in line 1694 below by control Factory.
In the function addValueHelp, two new object instances ValueHelpProvider and ValueListProvider are created. They will be used later when F4 is pressed.
Finally, in the rendering process, since now the currency field has value help assigned, the corresponding UI5 icon is rendered by InputRender so that end user can easily identify the field has value help supported.
We have just now mentioned ValueHelpProvider. When F4 is pressed, it will react the press event and create an instance of ValueHelpDialog, which is a composite control acting as a container for all UI elements you could see in the popup dialog.
The controls are created separately as shown below:
By default after you click F4 value help, the table is empty unless you click "Go" button.
The go button is implemented as instance of smartFilterBar created by ValueHelpProvider.
The event handler of search is defined in line 317, the function _onFilterBarSearchPressed. In this event handler, it will delegate to _rebindTable.
ValueHelpProvider.prototype._onFilterBarSearchPressed = function() {
this._rebindTable();
};
_rebindTable will fire a request to backend to ask for data for currency value list:
Once the response is available ( from mock data Currency.json in project ), the table is updated with data binding:
In the metadata, we have defined via annotation that the "Price" field has "CurrencyCode" field as its unit code.
Here below is the type definition for CurrencyCode, one property CURR for currency code and DESCR for currency description.
<EntityType Name="Currency">
<Key>
<PropertyRef Name="CURR" />
</Key>
<Property Name="CURR" Type="Edm.String" MaxLength="4"
sap:display-format="UpperCase" sap:text="DESCR" sap:label="Currency Code"
sap:filterable="false" />
<Property Name="DESCR" Type="Edm.String" MaxLength="25"
sap:label="Description" />
</EntityType>
It is this annotation which tells UI framework that once end user selects one currency from popup dialog, the value of field "CURR" in popup dialog must be passed back to field "CurrencyCode" in application.
How is this annotation parsed in the runtime? They are separately parsed in function addValueHelp we discussed previously and assigned to variable sValueListProprty and sLocalDataProperty.
When the first entry in currency list table is selected:
This selected state is passed into event handler via variable oControlEvent:
The key is parsed:
An event is raised with this selected key & text:
Now we are back to ValueHelpDialog:
Fire an OK event with selected key & text:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
9 | |
9 | |
8 | |
8 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |