Recognize links in h:outputText

巧了我就是萌 提交于 2019-12-13 03:07:21

问题


I need to show some text using <h:outputText> tag component. There is this requirement that if the text contains an URLs i.e. http//example.com.co, I need show it as a link.

For example, if user enters Yo quiero www.google.com I need to show Yo quiero www.google.com


回答1:


You need a function which does a regular expression replace on your string. You can use string.replaceAll() for this.

You have multiple options to place this function.

  1. You can create a method in your backing bean.
  2. You can create a custom jsf tag (example)
  3. You can create a custom el function (example)

No 1 is the easiest to implement imho.



来源:https://stackoverflow.com/questions/14698752/recognize-links-in-houtputtext

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!