Skip to Content
avatar image
Former Member

Create link in message Box - SAP Ui5

Lets say upon GRN posting , i received one message with link and when i click on link i get navigated to GRN page.

I want to know how to bring link on message box.

success.png (10.0 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    avatar image
    Former Member
    Jun 23, 2015 at 10:45 AM

    Thank You All for giving reply but my requirement is different , i am working with XML.

    Please find below the code.

    Layout.fragment.xml

    --------------------------------------------

    <core:FragmentDefinition

      xmlns="sap.m"

      xmlns:l="sap.ui.layout"

      xmlns:core="sap.ui.core">

    <l:VerticalLayout> 

         <Link

            text="{/message}"

            press="handleLinkPress" />

    </l:VerticalLayout>

    </core:FragmentDefinition>

    Master Controller.js

    var mess = res.error.message.value;

      var oData = {

           message : mess

         };

         var oModel = new sap.ui.model.json.JSONModel(oData);

         var oView = selfView.getView();

         oView.setModel(oModel);

       

         if (!this._oLayout ) {

           this._oLayout  = sap.ui.xmlfragment("cgi_GoodsReceipt_GRN.view.Layout", this);

      selfView.getView().addDependent(this._oLayout);      }

     

         sap.m.MessageBox.show(this._oLayout  , {

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

               title : "Successful Message",

               actions : [sap.m.MessageBox.Action.YES, sap.m.MessageBox.Action.NO],

               onClose : function(oAction) {

              

               },

               dialogId : "messageBoxId"

             });

    ----------------------------------------------------------------------------------------- event handler in Master Controller.js

    handleLinkPress : function(oEvent)

      {

      var unit = selfView.byId('Master--idUnitType1')

      .getValue();

      console.log(unit);

      debugger;

      },

    Now this handler is not getting triggered. And this is the issue which i am facing. I am getting link displayed in message box. when i click on link the handler is exepected to get triggered but it is not getting trigerred.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Correct Answer

      var link = new sap.m.Link({

               text: mess,              

               press:  [selfView.handleLinkPress, this]       

         });

        

        sap.m.MessageBox.show(link, {

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

                 title : "Successful Message",

                 actions : [sap.m.MessageBox.Action.YES, sap.m.MessageBox.Action.NO],

                  onClose : function(oAction) {

                  debugger;

                 },

                 dialogId : "messageBoxId"

               });

  • Jun 19, 2015 at 10:41 AM

    SAPUI5 Explored

    Custom Content add the

    link:"www.scn.sap.com"

    Add comment
    10|10000 characters needed characters exceeded

  • Jun 19, 2015 at 11:10 AM

    Create a link sap.m.Link and put it in your messageBox.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 19, 2015 at 02:00 PM

    Hi!

    var oButtonClose = new sap.m.Button({ text: "Close",
                                               type: "Reject" } );
                         oButtonClose.attachBrowserEvent('click',function(){ oDialogInfo.close(); });
                     var oDialogInfo =
                       new sap.m.Dialog({ title: "Your title",
                                  contentWidth: "400px",
                                  contentHeight: "320px",
                                  content: [
                     (new sap.m.Link({ text: "google.com - this link text",
                                                href: "google.com",

                                                target: "_self" })) //if new window "_blank"
                                              ],
                                        buttons: [ oButtonClose ]
                       });
                     oDialogInfo.open();


    Add comment
    10|10000 characters needed characters exceeded