So... I'm building an application that is basically a CRUD. On this application, I have the following views / controllers: VisitEdit and RequestNew.
At the RequestNew controller, I have a function that handles the press of a button:
onRequestNewAddCustomerPress: function(oEvent) {
if( !this.oAddCustomerDialog ){
this.oAddCustomerDialog = sap.ui.xmlfragment("com.sap.lccapp.fragment.AddCustomer", this);
}
this.oAddCustomerDialog.openBy(oEvent.getSource());
},
And I have at this same Controller the onExit function. It is now empty, because I have made a LOT of test with the .destroy() function of this object (oAddCustomerDialog) and it continues popping up the error.
The problem is; on the VisitEdit controller, when I try to use the same dialog for the second time, with the same code as above, it shows the following error:
Adding element with duplicate id 'addCustomerNameField'
The ID "addCustomerNameField" is from my first element inside my fragment.
Although I have the 'if verification' on both methods and because it is in different controllers, the last 'if' that is being verified has the object (this.oAddCustomerDialog) undefined (BUT IT SHOULD NOT HAS UNDEFINED VALUE) and it is creating again the sap.ui.xmlfragment.
Fragment definition: http://dontpad.com/stackoverflowquestionsapui5