首页 > SAP > SAPUI5 > Dynamic text in SAP Fiori Fragments
2019
08-27

Dynamic text in SAP Fiori Fragments

Hello every one, In our earlier tutorial we have introduced you to the concept of Fragments in SAPUI5/Fiori. If you have missed it,click here. In our last tutorial we have defined static text/data which are used in Fragments, in this tutorial we will try to push the text dynamically. Let see how we can do this. This is continuation to our earlier tutorial on Fragments,please refer to it before proceeding further.

1.  Follow the steps which exists in our last tutorial.

2. Revisit the code inside the Fragment file. We had declared a static text for the Text inside the Dialog like below.

3. Here we will dynamically pass the text to the fragments from the view controller. Here we are going to use the concept of model binding to achieve this.Go back to the view controller and write the below code to declare a model and add data to the model.

MainView.controller.js

4. What have we done onInit() method in previous step, we have declared a JSON model and set the data to the model and assign the model to the sap.ui.getCore() for globally access across the application.

[adsenseyu1]

5. Now go back the dialog fragment file and slightly change the code to get the text from model.Copy and paste the below code.
Dialog.fragment.xml

6. Now save the changes and test the application, output of the application should look similar to below.

7. The text displayed inside the popup dialog should be same as the text defined in the model in onInit() method of the view controller.

By this we will conclude this tutorial. Stay tuned to us for more SAPUI5 tutorials

最后编辑:
作者:yangsen
本站为个人博客网站,全由我个人维护,我从事SAP开发13年,其它ERP开发7年,基本都是零售行业。本站记录工作学习的过程, 有SAP相关询问专、兼职工作可随时联系我。 有网站相关的问题可直接在文章下方留言,或者联系我。 邮件:yan252@163.com给我。 QQ:415402519

留下一个回复

你的email不会被公开。