Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Function Call in Expression Binding in OpenUI5/SAPUI5

Problem is to print out the current year by using expression binding that was introduced with 1.28.

Expression Binding is capable of executing global accessible JS Functions.

Goal: Execute (new Date()).getFullYear() in expression binding

  • In this JSFiddle the first attempt is to execute a global string {:=Math.PI} => works
  • Second attempt is to define a global function window.temp = function() {return 'test'}; and to execute it via <Text text="{:=temp()}" /> => fail
  • Goal <Input value="{:=(new Date()).getFullYear()}" /> breaks parser and is in jsfiddle therefor outcommented. The Error Message is Expected ) but instead saw Date at position 9 - {:=(new Date()).getFullYear()} sap.ui.base.ExpressionParser

First question is: Why does the parser break? Is it a bug or am I doing something wrong?

Second question is: Even if the goal is not possible. Why is my second attempt also not working?

like image 756
monavari-lebrecht Avatar asked Jun 16 '26 03:06

monavari-lebrecht


1 Answers

I assume that the parser breaks as it does not support the new operator. Your second example is not working as only functions which are available via global symbols can be used. The window object is not listed there.

like image 124
matbtt Avatar answered Jun 18 '26 16:06

matbtt



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!