cancel
Showing results for 
Search instead for 
Did you mean: 

How to make url clickable in textarea/feedlistitem

Former Member
0 Kudos

Hi,

Is there someone who knows how I can search for url's in a textarea of feedlistitem and make them clickable?

I already tried this, but the loop doesn't work for me...

http://stackoverflow.com/questions/1500260/detect-urls-in-text-with-javascript

Regards,

RW

Accepted Solutions (1)

Accepted Solutions (1)

jmoors
Active Contributor
0 Kudos

Is the issue that you can't add the HTML syntax or the RegEx doesn't work? I believe for security reasons the controls escape the HTML to ensure you can't inject any harmful code for XSS attacks.

https://sapui5.hana.ondemand.com/sdk/#docs/guide/4de64e2e191f4a7297d4fd2d1e233a2d.html

The RenderManager writeAttributeEscape function calls  jQuery.sap.escapeHTML

Regards,

Jason

Former Member
0 Kudos

Jason,

Thanks for your reply. Do you have any suggestion how I could make a url clickable?

Regards,

RW

Former Member
0 Kudos

Hi Robbe,

I have not tried this but I think you can use event handler when clicking on the text area.

Please refer to the link below for more informaitn on event handler for SAP UI5:

Handling Events in Controls - User Interface Add-On for SAP NetWeaver - SAP Library

Regards,

Ashvin

jmoors
Active Contributor
0 Kudos

I guess you could extend the controls and implement your own renderer or onAfterRendering method to add the link HTML. However if you are relying on users entering the text, I think you would need to still perform some validation of the URL to ensure that you don't introduce any cross scripting security issues.

Regards,

Jason

Answers (1)

Answers (1)

Former Member
0 Kudos

Thanks guys, I got it working. I'll probably create a document about this, because I think this might be helpfull for other users to.

What I did was:

1: in the updateFinished event from my sap.m.list I call a function 'createURL'.

2. In the 'createURL' function I loop through all the objects of the same div class

3. Get the plain tekst with the html() function

4. Use autolinker (gregjacobs/Autolinker.js · GitHub ) to detect every url and create the a href tags.

5. replace the old html content with the new

The next thing I'll so is set up the validation.

Kind regards,

RW