Skip to Content

Open function at start app

Hello community, i have a question how can i open a dialog in the moment that i open my app? i have a view with a table and a button, that button opens a dialog

		oDialog : function () {
	         var oView = this.getView();
	         var oDialog = oView.byId("userDialog");
	         // create dialog lazily
	         if (!oDialog) {
	            // create dialog via fragment factory
	            oDialog = sap.ui.xmlfragment(oView.getId(), "", this);
	         }; // Abrimos el dialogo
		onCloseDialog : function () {

so i want to open this dialog with the button and in the moment that my app is opened (i thought to play with the cicle of life of my app especificly in my component but i don't know if this is possible and how), the other part if you have any idea is can i send data from this dialog to an odata the flow of the program it's like i open my app , a dialog is't opened, i introduce an user , consume an odata filtering with that id and show the results in the table

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Mar 06, 2018 at 06:37 AM

    In the controller you can add a onInit function. That will whatever inside it. Then you can cal oDialog like this

    onInit: function(){ 

    if you want to pas data from one controller to another you can use the router or the eventBuss

    On the receiver side:

    var eventBus = sap.ui.getCore().getEventBus();  
    eventBus.subscribe("someTasks", "dataSuccess", this.functionName, this);
    On the sender side
    sap.ui.getCore().getEventBus().publish("someTasks", "dataSuccess", oData);
    Add comment
    10|10000 characters needed characters exceeded

    • Thank you Naoto Amari that is nice to hear :). Most of what i code is in private repos :'( But this is my github:

      the result from makeRequest will contain a oData object. So in the function getText

         var someModel = new sap.ui.model.json.JSONModel();
      this.getView().setModel(someModel, "modelName");

      Then you can use modelName