cancel
Showing results for 
Search instead for 
Did you mean: 

MessageBox not displayed in Firefox

Former Member
0 Kudos

Hi there,

in my application running on WAS Java 7.40 SP09 (Sapui 1.24) I discovered that message boxes are not displayed in Firefox 36.

I've tried the following:


jQuery.sap.require("sap.m.MessageBox");

sap.m.MessageBox.show("Test", {

                                icon : sap.m.MessageBox.Icon.ERROR,

                                title : "Error"

});

and also


sap.ui.commons.MessageBox.alert("Hello");

But no text box is displayed.

In Chrome/IE it works.

Is that a known issue?

Thanks in advance.

Best regards,

Thorsten.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

I've now found out that it seems only to fail if the message box should be created in a success method of a OData call:


checkTask : function(taskId) {

                        var oTasksODataModel = sap.ui.getCore().getModel(

                                "tasksODataModel");

                        oTasksODataModel.read("/TaskCollection('" + taskId

                                + "')", null, null, true, fSuccess, fError);

                        function fSuccess(oEvent) {

                            sap.ui.commons.MessageBox.alert("Hello");

                        };

                         function fError(oEvent) {

                            sap.ui.commons.MessageBox.alert("Hello2");

                        };

}

What is the best practice to display messages in those kind of methods???

Former Member
0 Kudos

Hi Thorsten,

Maybe you should declare both functions before the checkTask function

or


   checkTask : function(taskId) { 

                            var oTasksODataModel = sap.ui.getCore().getModel( 

                                    "tasksODataModel"); 

                            oTasksODataModel.read("/TaskCollection('" + taskId 

                                    + "')", null, null, true, function (oEvent) { 

                                sap.ui.commons.MessageBox.alert("Hello"); 

                            }, function (oEvent) { 

                                sap.ui.commons.MessageBox.alert("Hello2"); 

                            }

); 

}

Former Member
0 Kudos

I've now succeeded by moving the method call from the onInit() to the onBeforeRendering() method:


onBeforeRendering : function() {

  

    var taskId = getValueOfURLParameter("taskId");

  

    // Check if task is not processed yet

    this.checkTask(taskId);  

},

This is the checkTask(taskId) method:


checkTask : function(taskId) {

    var oTasksODataModel = sap.ui.getCore().getModel("tasksODataModel");

    oTasksODataModel.read("/TaskCollection('" + taskId

                            + "')", null, null, true, fSuccess, fError);

  

    function fSuccess(oEvent) {

        console.log("Task read successfully!");

        var status = oEvent.Status;

        var processor = oEvent.Processor;

        var user = getUser();

        if (status == "COMPLETED") {

            // Task has already been completed

            sap.ui.commons.MessageBox.alert("Task has already been completed");

            return;

        }

        if (status == "RESERVED") {

            // Task is reserved

            if (processor != "" && processor != user.toLowerCase()) {

                // Processor != current user      

                sap.ui.commons.MessageBox.alert("Task has already been reserved by " + processor);

              

                return;

            }

        }

    };

}

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Thorsten,

What I usually do in my model is to declare a generic function that I call upon successful completion of the oData call and on other one for error.

The generic function for success looks like:


model.DataService.loadSuccess = function(data,response, dataObject) {

  var resultData;

  var headers;

  headers = response.headers;

if(data){

       if (data.results !== undefined) {

       // It is a collection

            resultData = data.results;

       } else {

       // It is not a collection

            resultData = data;

       }

  } else {

       // its a delete so no response body...

       resultData = {};

  }

  sap.ui.getCore().getEventBus().publish("data", dataObject.serviceType, {

       results : resultData,

       dataObject : dataObject,

       headers : headers,

       response: response

  });

};

As you can see this function uses the EventBus to trigger the desired action on the controller(s) having subscribed to the correct channel ("data") and correct "event" (dataObject.serviceType). It allows me to trigger actions or refresh on the desired controllers and to display the message box from within the desired controller. This works fine for me on all browsers.

The same logic is applied in the error function.

For information, here is a sample of code for the oData call itself using this generic function:


model.DataService.loadData = function(content,url,context,parameterArray,serviceId) {

  var model;

  var thisInstance;

  thisInstance = this;

  model = this.getModel(serviceId);

 

  if (model !== null) {

  // We are in an online scenario

       model.read(url, context, parameterArray, true, function(data,response) {

            thisInstance.loadSuccess(data,response, {

                serviceType : content.serviceType,

                 errServiceType : content.errServiceType

            });

       },function(oError){

            thisInstance.loadError(oError,url,{

                 serviceType : content.serviceType,

                 errServiceType : content.errServiceType

            });

       });

  } else {

  // We are in an offline scenario with mockdata

  }

};

I hope this helps!

Jon