2014-11-03 15 views
-1

我正在开发一个使用Primefaces 5的应用程序,部分应用程序允许用户发布信息,例如发布此用户的信息>>>“请kim访问www.primefaces.org和在那里读abt primefaces“。问题是我希望URL在被其他用户看到时发布为超链接。下面的代码中的粗体部分显示了发布的消息。将发布的网址解释为一个超级链接在黄金时段

<div id="postcontent_div"> 
     <h:panelGrid columns="1" style="background-color: #fff;padding-top: 0px;border-bottom: 1px solid #fff"> 
      <p:commandLink styleClass="profilenamelink" ajax="false" value="#{post.username} "/> 
      <h:outputText value="How to master Algorithms" style="font-size: 12px;font-weight:bold;color:black"/> 
     </h:panelGrid> 
     <h:outputText value="#{post.message}" style="font-size: 12px"/> 
    </div> 

回答

0

随着primefaces <p:link>。 见文档:http://www.primefaces.org/showcase/ui/button/link.xhtml

在默认的JSF实现<h:outputLink> 查看文档:http://www.jsftoolbox.com/documentation/help/12-TagReference/html/h_outputLink.html

编辑:

如果你想从一个String解析URL,有可用一些方法。看到类似的回答:Recognize links in h:outputText

+0

谢谢@Thrax快速回复。从用户发布带有URL的消息的问题,如“请kim访问www.primefaces.org并阅读关于primefaces”。当使用显示消息时,URL www.primefaces.org网址应该被自动解释为超链接,但它不会发生。我该怎么办呢? – Bento 2014-11-03 14:07:34

+0

@Bento查看更新的答案 – Thrax 2014-11-03 14:42:27