on 06-19-2015 11:37 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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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"
});
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();
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Same code is working fine for me, just i added "https://" infront of "google.com"
In my view.xml,
<Button id="" text="open" press="open" />
In my Controller.js,
open: function() {
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: "https://google.com",
target: "_self" })) //if new window "_blank"
],
buttons: [ oButtonClose ]
});
Create a link sap.m.Link and put it in your messageBox.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Will this help?
Hi!
This code have error and not exist property href in sap.m.Link, please paste this code:
jQuery(function() {
jQuery.sap.require('sap.m.MessageBox');
function fnCallbackMessageBox(oAction) {
console.log(oAction);
}
var link = new sap.m.Link({text : "click here",
href:"http://google.com",
target: "_blank"
});
sap.m.MessageBox.show(
link, {
icon: sap.m.MessageBox.Icon.QUESTION,
title: "Link in message box",
actions: [sap.m.MessageBox.Action.OK, sap.m.MessageBox.Action.CANCEL],
onClose: fnCallbackMessageBox
});
});
JS Bin - Collaborative JavaScript Debugging
Even there is a press event in sap.m.Link.
If used href it opens in the same tab
User | Count |
---|---|
85 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.