Openui5: Expression Binding: logical operator && not working

Created on 8 Aug 2016  路  3Comments  路  Source: SAP/openui5

OpenUI5 version: 1.38.5

Browser/version (+device/version): Chrome 51

Any other tested browsers/devices(OK/FAIL): FAIL

Steps to reproduce the problem:

  • Basic UI5 Projekt with Complex Binding
  • Following will work

    • <Button text="Test" visible="{= true || true }" />

  • Following will fail

    • <Button text="Test" visible="{= true && true }" />

What is the expected result?

  • The calculated value should be true

What happens instead?

  • No view is displayed.
  • Check for 'file not found' or parse errors. Reason: Error: Invalid XML

Any other information? (attach screenshot if possible)

Most helpful comment

I faced this problem, too, and was able to solve it by escaping '&' as XML-Entity '&&'

So this should work:
<Button text="Test" visible="{= true &amp;&amp; true }" />

Updated Plunker here: https://plnkr.co/edit/nCJm9bXTqkOo7vgHkKCf?p=preview

All 3 comments

I faced this problem, too, and was able to solve it by escaping '&' as XML-Entity '&&'

So this should work:
<Button text="Test" visible="{= true &amp;&amp; true }" />

Updated Plunker here: https://plnkr.co/edit/nCJm9bXTqkOo7vgHkKCf?p=preview

That's true. Not sure whether our documentation was helpful here. On https://sapui5.hana.ondemand.com/#docs/guide/daf6852a04b44d118963968a1239d2c0.html it says (somewhere) "Some characters that are used by operators, however, need to be escaped in XML, for example the left angle bracket (<) and the ampersand (&)."

Ah ok. Thank you for that hints. Didn't notice that information in the documentation in the first place. So I think this issue can be closed.

Greetings,
chumbalum

Was this page helpful?
0 / 5 - 0 ratings