Let's follow up this discussion at the Neptune Community

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

Message Area

Hi 


I am trying to implement the messageArea example that you have on neptune explored i.e. #neptune.MessageArea


I cannot find Object / Message Area / neptune.MessageArea, i can only find sap.m.messageArea.


Ho do I implement this.

I have implemented the back end code to raise the message

CALL METHOD iv_server->api_message_create
EXPORTING
message = ls_message.


but how do I get it to the ui and bind the messageArea to the response.


Thanks


Darren


Best Answer

Hi Darren


Thank you for sharing this code. Really nice one.


Will look into how we can implement this solution into Neptune


Regards

Ole Andre 


Hi Darren


You are using the right object. sap.m.MessageArea - in Explored we have called it in our namespace, since it is a custom object from Neptune. 


You are using the API right, so having the sap.m.MessageArea on the page will display the Message Content.


Regards

Ole Andre 

Hi Ole Andre 


Thanks for responding, but my problem is that it is not displaying.  I have implemented exactly as is in the messageArea example.


I put a message area on the page.

I created an ajax call and  add the message using server->api_message_create

EXPORTING
message = ls_message.


Thanks


Darren

Hi Ole Andre


I am getting simple messages out now.

I seem to be having some issues when using message classes, I will dig further with it.


Thanks

Hi Ole Andre


The messages will not display when I enter a value into the FIELD_NAME property.

I have a field on a form called inoSimpleFormLIFNR.  If i fill out the message structure with the following I get no message


 ls_message-field_name = 'inoSimpleFormLIFNR'.      "This is causing the issue.
ls_message-type = 'E'.
ls_message-id = 'ZWF_FORMS'.
ls_message-number = '000'.
ls_message-message_v1 = 'DEMO'.


Am I using the FIELD_NAME param correctly ?  


Many thanks


Darren

Hi Darren


Using the FIELD_NAME is the field name of the MessageArea object. If you have several MessageArea this would send the messages to the right object.


Regards

Ole Andre 

Thanks, that makes sense.


Is there anyway to target the form input box that the message relates to.


Eg. I have a vendor input called noSimpleFormLIFNR,  I validate this field in the back end, and I want to set the value state of the input box to error.



Hi Ole Andre 


I was able to target the elements on my form.  I created a table on the application class called gt_messages.


I append all messages to this class, and send it back to the ui. I call the below javascript and it works pretty well.


I think this would be a nice feature for you to implement and it should be pretty easy.


function setFormItemsValueState( ){


  var message = modelMessages.getData( );

  $.each(message, function (i, data) {

      console.log('Message ' + i + ' ' + data.FIELD_NAME);

      if (data.FIELD_NAME.length > 0)

      var theField = sap.ui.getCore().byId(data.FIELD_NAME);

      var theType = data.TYPE;

      var theMess = data.MESSAGE;

      console.log( theType + ' ' + theMess);

      var valueState = 'None';


      if (typeof theField != 'undefined') {

        if (theType == 'E') {

          valueState = 'Error';

        }

        else if(theType == 'S') {

          valueState = 'Success';

        }

        else if(theType == 'W') {

          valueState = 'Warning';

        }

        else{

            valueState = 'None';

        }


        try{

          theField.setValueState(valueState);

          theField.setValueStateText(theMess);

        }

        catch(error){


        }

      }

   });


}


Thanks


Darren


Answer

Hi Darren


Thank you for sharing this code. Really nice one.


Will look into how we can implement this solution into Neptune


Regards

Ole Andre 

Login or Signup to post a comment