0

How can i use if/else conditions to render any view dynamically in UI5. i found this, which seemed for me a proper solution:

How to use an if-else condition in a SAPUI5 XML-View?

But this does not work because the xmlns attribute xmlns:template="http://schemas.sap.com/sapui5/extension/sap.ui.core.template/1"

does not work.

So how to solve this problem? I did not found any other template link.

  • I use the second approach of the Content of the link.It is more complicated but the first approach does not work. – Pulse Drone Apr 26 '20 at 15:46
  • The first approach ([XML templating](https://openui5.hana.ondemand.com/topic/5ee619fc1370463ea674ee04b65ed83b)) is currently not supported with routing. But it's in the roadmap. – Boghyon Hoffmann Apr 26 '20 at 16:39
  • ok, nice to know. How do you know that? – Pulse Drone Apr 26 '20 at 16:58
  • You mean that it's in the roadmap? You can see roadmaps for SAP products in https://www.sap.com/products/roadmaps/finder-all.html. Search by "ui5" for SAPUI5 roadmap. You need an account though. For OpenUI5, it's in https://openui5.org/OpenUI5_Roadmap.pdf – Boghyon Hoffmann Apr 26 '20 at 17:56
  • this never worked. Don't do it. Every aggregation can have a factory function. Everything else is to complex – Benedikt Kromer Apr 27 '20 at 13:29
  • Agree with @bkr. Even if the router supports XML templating, it's an overkill and too static (the template tags apply only once during the view instantiation). If the amount of the target controls is small, simply switching the visibility of them might be a good-enough but maintainable solution. – Boghyon Hoffmann May 05 '20 at 12:06

1 Answers1

0

Have a look at Expression binding

Example:

<Text text="I am text" visible={= ${viewModel>/bIsTextVIsible} || ${viewModel>/bAnotherCondition} } />
Lumpenstein
  • 1,250
  • 1
  • 10
  • 27