Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"FormatException in property ... " error despite valid Expression Binding syntax

Tags:

sapui5

I would like to display a sap.m.Button in case the value of two model properties are equal. It that possible via expression binding.

Bindings:

  • {user-management>/alias}
    • value: "TESTUSER"
  • {recipe-service>Author/alias}
    • value: "TESTUSER"

My attempts:

<Button xmlns="sap.m" visible="{= ${user-management>/alias} === ${recipe-service>Author/alias}}" />
<!-- or: -->
<Button xmlns="sap.m" visible="{= ${user-management>/alias} === ${recipe-service>Author/alias} ? true : false}"/>

The above attempts are not working resulting with the following console error:

FormatException in property 'visible' of 'Element sap.m.Button#__button1': TESTUSER is not a valid boolean value Hint: single properties referenced in composite bindings and within binding expressions are automatically converted into the type of the bound control property, unless a different 'targetType' is specified. targetType:'any' may avoid the conversion and lead to the expected behavior.

I am not aware of using targetType for expression binding.

like image 573
babdo Avatar asked Apr 22 '26 17:04

babdo


1 Answers

You must be using an OData V4 service. In that case, replace $ with % within the expression binding where the V4 OData model value is embedded but causes the above error.

Assuming the latter "recipe-service" model is sap.ui.model.odata.v4.ODataModel:

<Button xmlns="sap.m" visible="{= ${user-management>/alias} === %{recipe-service>Author/alias}}" />

See also the information about the automatic type determination in topics Changes Compared to OData V2 Model and Type Determination.

like image 124
Boghyon Hoffmann Avatar answered Apr 28 '26 12:04

Boghyon Hoffmann



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!