title: sap.m.Dialog Shows Duplicate ID Error on 2nd Open
body: <p>I am opening a dialog after clicking a button and filling some info into it. When I open the dialog once again it displays the error: </p>
  
  <pre><code> Error: adding element with duplicate id '__xmlview1--__item0'
  </code></pre>
  
  <p>Below is the code : 
  (Edited : saving the create dialog instance everytime the dialog is created) </p>
  
  <pre><code>        onAddMovie: function() {
          var view = this.getView();
          var createDialog = view.byId("CreateDialog");
  
          var oDummyController = {
              // This is when I clicked the Submit button in dialog
              submitDialog: function() {
              view.byId("panel").setVisible(true);
  
              user = view.byId("movie_name").getValue();
              var label = view.byId("movieName");
              label.setText(user);
  
              screenDate=view.byId("screeningDate").getValue();
              var date = view.byId("__date");
              var dateObject = new Date(screenDate);
              var dateFormat = sap.ui.core.format.DateFormat.getDateInstance({pattern : "MMM dd,YYYY" }); 
              var dateFormatted = dateFormat.format(dateObject);
              date.setText(dateFormatted);
  
  
              rating=view.byId("langRating");
              var radioRating= view.byId("movieRating").getSelectedButton().getText();
              if(radioRating == "Universal")
             { radioRating='(U)'; }
              else if(radioRating == "Adult")
              {
                  radioRating='(A)';
              }
              else
              {
                      radioRating='(U/A)';
              }
  
  
              rating=view.byId("langRating");
              rating.setText(radioRating);
  
                  MessageToast.show(user);
                  createDialog.close();
              },
              closeDialog: function() {
                  createDialog.close();
              }
          };
          // This is when the dialog event is fired, things are fine here
          if (!createDialog) {
              createDialog = sap.ui.xmlfragment(view.getId(), "Admin.view.Dialog", oDummyController);
          }
  
            if (this._createDialog) {
         this._createDialog = sap.ui.xmlfragment(view.getId(), 
         "Admin.view.Dialog", oDummyController);
        }
          view.addDependent(createDialog);
          createDialog.open();
          if (!createDialog.isOpen()) {
              //do sth
          }
      }
  </code></pre>
  
  <p>fragment : </p>
  
  <pre><code>         &lt;core:FragmentDefinition  xmlns="sap.m" xmlns:core="sap.ui.core" 
             xmlns:l="sap.ui.layout"&gt;
  
                  &lt;Dialog  title="Input Movie Details" width="100%" 
            class="sapuiMediumMargin" confirm="handleClose" 
               close="handleClose"&gt;
                      &lt;l:VerticalLayout class="sapUiContentPadding" width="100%"&gt;
                      &lt;l:content&gt;
                          &lt;Input width="100%" placeholder="Movie Name" id="movie_name"/&gt;
                          &lt;HBox alignItems="Center" renderType="Bare"&gt;
                              &lt;Label text="Year of Release" width="50%"/&gt;
                              &lt;ActionSelect selectedItem="Element sap.ui.core.ListItem#__item0" selectedKey="item1" class="sapUiLargeMarginBegin" selectedItemId="__item0" id="yearOfRelease" width="50%"&gt;
                                  &lt;items&gt;
                                      &lt;core:ListItem text="2017" key="item1" id="__item0"/&gt;
                                      &lt;core:ListItem text="2016" key="item2" id="__item1"/&gt;
                                      &lt;core:ListItem text="2015" key="item3" id="__item2"/&gt;&lt;/items&gt;
                              &lt;/ActionSelect&gt;
                          &lt;/HBox&gt;
                          &lt;HBox alignItems="Center" renderType="Bare"&gt;
                              &lt;Label text="Date of Screening" width="50%"/&gt;
                              &lt;DatePicker class="sapUiLargeMarginBegin" width="50%" id="screeningDate"/&gt;
                          &lt;/HBox&gt;
                          &lt;HBox alignItems="Center"&gt;
                              &lt;Label text="Movie Rating"/&gt;
                              &lt;RadioButtonGroup width="100%" columns="3" selectedIndex="-1" id="movieRating"&gt;
                                  &lt;buttons&gt;
                                      &lt;RadioButton  groupName="__group0" text="Universal" id="__button0"/&gt;
                                      &lt;RadioButton groupName="__group0" text="Adult" id="__button1"/&gt;
                                      &lt;RadioButton groupName="__group0" text="U/A" id="__button2"/&gt;&lt;/buttons&gt;
                              &lt;/RadioButtonGroup&gt;
                          &lt;/HBox&gt;
                                  &lt;HBox alignItems="Center" width="100%" renderType="Bare"&gt;
                              &lt;Label text="Enable Booking" width="70%"/&gt;
                          &lt;CheckBox id="enableBooking" width="30%" textDirection="LTR"/&gt;
                      &lt;/HBox&gt;
                          &lt;FlexBox alignItems="End" alignContent="Center" justifyContent="End" class="sapUiTinyMarginTop"&gt;
  
  
                              &lt;SegmentedButton selectedButton="__button3" id="__button21"&gt;
                                      &lt;buttons&gt;
                                          &lt;Button text="Submit" id="__submit" press="submitDialog"/&gt;
                                          &lt;Button text="Cancel" id="__button41" press="closeDialog"/&gt;&lt;/buttons&gt;
                                  &lt;/SegmentedButton&gt;
                                      &lt;/FlexBox&gt;
                          &lt;/l:content&gt;
                      &lt;/l:VerticalLayout&gt;
                  &lt;/Dialog&gt;
  
              &lt;/core:FragmentDefinition&gt;
  </code></pre>
  
  <p>Please help as I am new to Javascript and SAPUI5</p>