on 11-15-2018 8:27 AM
Hi All,
We are getting a getting a String with multiple URLs ( different url based on the back end logic). I am using XML view , where I have tried the Text and Label to show the String.
In the controller I am using following code to convert the URL as hyperlink
resString = tempString.replace(/(\b(https?|ftp):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gim, '<a href="$1" target="_blank">$1</a>');
and after this I am using
this.getView().byId("__text").setText(resString );
But it appear as the simple text.
Kindly suggest.
_vishal
There is an UI5 control 'sap.m.Link' which can be used for this scenario. I hope it is not the case where you are using m.text instead of m.link for some reason.
If it is the case then to change text to link, you need to get the html and do it as i think sap.m.text wont allow us to change the format of text(If i remember). see the link below for ref.
https://archive.sap.com/discussions/thread/3854797
BR,
Mahesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mahesh,
Thanks for response.
We do not want to makes the entire string as the hyperlink.
let us assume, If we are getting following string from the back end
tempString = You can search at google . https://www.google.com. OR you can also search at https://help.sap.com.
then the the requirement is make the hyperlinks for URL section only, rest text should appear as it is.
_vishal
the link shared ( discussion thread) help to resolve the issue.
Thanks
_vishal
You can change the text to link. something like this:
<m:Link id="link"/>
resString = tempString.replace(/(\b(https?|ftp):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gim, '$1');
this.getView().byId("link").setHref(resString);
this.getView().byId("link").setText(resString);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Nicholas,
Thanks for response.
It makes the entire string as the hyperlink.
If we are getting following string from the back end
tempString = You can search at google . https://www.google.com. OR you can also search at https://help.sap.com.
then the this solution is making entire tempString as hyperlink. But the requirement is make the hyperlinks for URL section only.
rest text should appear as it is.
_vishal
User | Count |
---|---|
83 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.