on 07-04-2017 8:22 AM
Hi All,
I have few doubts in using SAP.M.LINK.
Through my oData, I am passing multiple links/URLs to my front end. These links will be available under "Attachments" label.
I am getting the value of my 1st link as -
var Link1 = sItem.getBindingContext().getProperty("Link1");
and similary...
var Link2 = sItem.getBindingContext().getProperty("Link2"); and other links.
I tried using the below syntax, but it does not navigate to my URL(even when Link1 has correct value). When I hard coded, a URL in my HREF property, it got successfully navigated to that URL. I am not able to find an error in debug mode.
Please help me with what I am doing wrong.
Thanks
Meenakshi
Hi
Please find below the view definition. I guess in your case the model which your binidng is more important. I created and XML view
<mvc:View controllerName="mysap.ui5.demo.walk.controller.App" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m" xmlns:u="sap.ui.unified">
<App>
<pages>
<Page title="{i18n>title}">
<content>
<!--<u:Currency value="2300.12" currency="INR" useSymbol="true" />-->
<Text text="{ path: '/number', type: 'sap.ui.model.type.Currency', formatOptions: { showMeasure: false } }"/>
<!--<Text text="Hello World"/>-->
<Link id="Test" text="Link1" href="{path: '/link1'}"></Link>
<Link id="Test2" text="Link2" href="{path: '/link2'}"></Link>
</content>
</Page>
</pages>
</App>
</mvc:View>
The controller definition is as follows
sap.ui.define([
"sap/ui/core/mvc/Controller", "sap/ui/model/json/JSONModel",
"sap/ui/core/format/NumberFormat"
], function(Controller, JSONModel, NumberFormat) {
"use strict";
return Controller.extend("mysap.ui5.demo.walk.controller.App", {
_data: {
"number": ["9999.99"],
"link1" : 'https://www.google.com',
"link2" : 'https://www.aol.com'
},
onInit: function(evt) {
var oModel = new JSONModel(this._data);
this.getView().setModel(oModel);
var oFmtSet = NumberFormat.getCurrencyInstance();
// var oLocale = oFmtSet.getCurrencyInstance();
}
});
});
Thanks,
Pavan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
For me, it looks fine irrespective of the view type. As I mentioned earlier the model which you have bound to the view could be making the difference.
sap.ui.jsview("mysap.ui5.sandappSandApplication.view.Main", {
getControllerName: function() {
return "mysap.ui5.sandappSandApplication.controller.Main";
},
createContent: function(oController) {
var oPage = new sap.m.Page({
title: "{i18n>title}",
content: [
new sap.m.Link({
id: "link1", // sap.ui.core.ID
text: "Link1", // string
href: "{path: '/link1'}" // sap.ui.core.URI
}
),
new sap.m.Link({
id: "link2", // sap.ui.core.ID
text: "Link2", // string
href: "{path: '/link2'}" // sap.ui.core.URI
}
)
]
});
var app = new sap.m.App("myApp", {
initialPage: "oPage"
});
app.addPage(oPage);
return app;
}
});
<br>
Here is the controller,
sap.ui.define([
"sap/ui/core/mvc/Controller" , "sap/ui/model/json/JSONModel",
"sap/ui/core/format/NumberFormat"
], function(Controller, JSONModel, NumberFormat) {
"use strict";
return Controller.extend("mysap.ui5.sandappSandApplication.controller.Main", {
_data: {
"number": ["9999.99"],
"link1" : 'https://www.google.com',
"link2" : 'https://www.aol.com'
},
onInit: function(evt) {
var oModel = new JSONModel(this._data);
this.getView().setModel(oModel);
var oFmtSet = NumberFormat.getCurrencyInstance();
// var oLocale = oFmtSet.getCurrencyInstance();
}
});
});
<br>
Please find the screen shot below
Thanks, Pavan
I dont know why it did not work. So i used window.open(Link1);
this is working in my case. Thanks a lot 🙂
Hi,
If you are getting the link from an OData service, you could simply use URLHelper to redirect to a new page.
example:
sap.m.URLHelper.redirect(oData.results[0].Link,true);
Thanks,
Saira
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Meenakshi,
Can you try with 'Press' event in sap.m.Link..
https://openui5.hana.ondemand.com/#docs/api/symbols/sap.m.Link.html#event:press
I am not sure are you setting href value dynamically for the link.
Regards,
Mahi theja
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
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.