Let's follow up this discussion at the Neptune Community

(this forum will be kept in read-only mode)

MessagePopover problem on first message

Hi all

I am facing some problems about control MessagePopover. 

1) First of all, I would like to understand if the object sap.m.MessagePopoverItem works correctly on NAD. I tried to set one of this item under the control MessagePopover but with no effect. Also the sample at MessagePopover Sample have more Item under popover in the designer but when running app, no message is shown

Anyway this first point is just a curiosity: I don't think it's essential setting message in NAD as is important showing message at runtime with JS. So I made a page with textarea and a button to submit text into MessagePopover for testing Javascript object method. 

2) The real problem I faced is this: when I set a message with MessagePopover.insertItem method, no message is shown in the control until it has been opened at least one time. With JavaScript I retrieve also number of elements of object (to show number of message on button for opening the MessagePopover) and while insert I can see number growing but when I open control is empty. Once opened, it works correctly for the rest of "app execution" and above method works correctly as I expected (so that I used an ugly trick: before insert new message item in popover I call twice the method toggle for being sure control has been opened at least once).  Here is the code of the button adding item in MessagePopover: 

  

// get textarea content
var insert_message = MsgTextPopover.getValue();

// create new item for MessagePopover
var po_item = new sap.m.MessagePopoverItem();

// set its properties
po_item.setDescription("Messaggio " + insert_message);
po_item.setTitle(insert_message);

// XXX message type
po_item.setType(sap.ui.core.MessageType.Error);

// trick
 oMessagePopover.toggle(this);
 oMessagePopover.toggle(this);

// insert new item in MessagePopover
oMessagePopover = oMessagePopover.insertItem(po_item,1);

// retrieve message number in MessagePopover ...
var items = oMessagePopover.getItems();

// ... and set number of message on button
ButtonMessagePopover.setText("Messaggi: " + items.length );

// XXX button style
ButtonMessagePopover.setType(sap.m.ButtonType.Reject); 

 Am I missing something? 


Thanks and regards

Gabriele

1 Comment

Hi Gabriele,


The MessagePopOver example was incomplete, so a big thank you for the heads up !   


sap.m.MessagePopoverItem works as an aggregation of  sap.m.MessagePopover.  Typically you will bind sap.m.MessagePopOver to a table which gets populated with the messages in the backend processing.


I have corrected the MessagePopover Sample  so you can check it out.   Please remember that you can always check the ABAP code by clicking on 


Have a nice week and happy coding :)   kind regards,

Julian

Login or Signup to post a comment