<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: UI5: using dialog across different views in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/ui5-using-dialog-across-different-views/qaa-p/12677545#M4756601</link>
    <description>&lt;P&gt;It seems like your error is rather related to your fragment itself.. are you able to load it at all? &lt;/P&gt;&lt;P&gt;The benefit of a fragment is its reusability and not needing to define the controller. So generally, every time you call the fragment from anywhere, you can define the controller as "this". All custom functions should then be loaded from the respective controller and can be redefined in other controllers.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;if(this.oMsgDialog){
Fragment.load({name:"namespace.fragment.MsgDialog", controller: this})
.then(function(dialog){
this.oMsgDialog = dialog; 
this.getView().addDependent(dialog);
dialog.open();
}.bind(this));
}else{this.oMsgDialog.open();
}&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 27 Feb 2023 22:53:35 GMT</pubDate>
    <dc:creator>leonikussmaul</dc:creator>
    <dc:date>2023-02-27T22:53:35Z</dc:date>
    <item>
      <title>UI5: using dialog across different views</title>
      <link>https://community.sap.com/t5/technology-q-a/ui5-using-dialog-across-different-views/qaq-p/12677544</link>
      <description>&lt;P&gt;Dear experts,&lt;/P&gt;
  &lt;P&gt;I have to decide how to design my code to use single dialog across different views.&lt;/P&gt;
  &lt;P&gt;I wrote my dialog as fragment (&lt;A href="https://answers.sap.com/storage/temp/2131028-testfragment.xml" data-attachment="2131028"&gt;testfragment.xml&lt;/A&gt;) and I'm using SAPUI5 v.1.96.14&lt;/P&gt;
  &lt;P&gt;The following are some solutions I have explored:&lt;/P&gt;
  &lt;P&gt;&lt;STRONG&gt;1. Connect custom controller to the fragment&lt;/STRONG&gt;&lt;/P&gt;
  &lt;P&gt;Following this &lt;A href="https://blogs.sap.com/2019/01/22/how-to-split-code-in-sapui5-by-using-fragments-and-xml-view/" target="_blank"&gt;post&lt;/A&gt; I tried to link the Dialog with its custom controller:&lt;/P&gt;
  &lt;UL&gt;
   &lt;LI&gt;I have to use sap/ui/core/Fragment instead of this.loadFragment beacuse you can't connect a custom controller with the last one&lt;/LI&gt;
   &lt;LI&gt;I'm facing the following error &lt;/LI&gt;
   &lt;LI&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2131034-image.png" /&gt;&lt;/LI&gt;
  &lt;/UL&gt;
  &lt;P&gt;&lt;STRONG&gt;2. Write custom function inside a custom controller&lt;/STRONG&gt;&lt;/P&gt;
  &lt;P&gt;In my project all views are extended to a BaseController that contains custom functions.&lt;/P&gt;
  &lt;P&gt;I could put all the custom functions of my dialog inside the BaseController.&lt;/P&gt;
  &lt;P&gt;&lt;STRONG&gt;3. Create the dialog via javascript instead of fragment&lt;/STRONG&gt;&lt;BR /&gt;&lt;/P&gt;
  &lt;P&gt;I could create my dialog using javascript with new sap.m.Dialog command inside BaseController.&lt;/P&gt;
  &lt;P&gt;I prefer to avoid this option because the dialog will be complex.&lt;/P&gt;
  &lt;P&gt;I am not using nested views because they are not needed with dialog.&lt;/P&gt;
  &lt;P&gt;Does anyone have any advice or other ideas?&lt;/P&gt;
  &lt;P&gt;Thanks&lt;/P&gt;
  &lt;P&gt;&lt;EM&gt;Fabio&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jan 2023 11:49:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/ui5-using-dialog-across-different-views/qaq-p/12677544</guid>
      <dc:creator>fabio_ubbiali</dc:creator>
      <dc:date>2023-01-30T11:49:32Z</dc:date>
    </item>
    <item>
      <title>Re: UI5: using dialog across different views</title>
      <link>https://community.sap.com/t5/technology-q-a/ui5-using-dialog-across-different-views/qaa-p/12677545#M4756601</link>
      <description>&lt;P&gt;It seems like your error is rather related to your fragment itself.. are you able to load it at all? &lt;/P&gt;&lt;P&gt;The benefit of a fragment is its reusability and not needing to define the controller. So generally, every time you call the fragment from anywhere, you can define the controller as "this". All custom functions should then be loaded from the respective controller and can be redefined in other controllers.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;if(this.oMsgDialog){
Fragment.load({name:"namespace.fragment.MsgDialog", controller: this})
.then(function(dialog){
this.oMsgDialog = dialog; 
this.getView().addDependent(dialog);
dialog.open();
}.bind(this));
}else{this.oMsgDialog.open();
}&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 27 Feb 2023 22:53:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/ui5-using-dialog-across-different-views/qaa-p/12677545#M4756601</guid>
      <dc:creator>leonikussmaul</dc:creator>
      <dc:date>2023-02-27T22:53:35Z</dc:date>
    </item>
  </channel>
</rss>

