2012-03-21 30 views
0

我想使用primefaces dataExporter導出一些數據,並且我有一列有一個人名和名稱是一個鏈接到外部網站。試圖讓primefaces dataExporter顯示鏈接而不是url的值

本來我有以下的代碼,然後我發現this線程它說,H:commandLink現在由dataExporter

<p:dataTable var="inv" value="#{personBacker.investigators}" id="tbl" rows="50" effect="true"> 

    <p:column filterBy="#{inv.name}" headerText="Investigator" filterMatchMode="contains"> 
     <h:outputLink value="http://example.com/"> 
      <h:outputText value="#{inv.name}" /> 
     </h:outputLink> 
    </p:column> 

</p:dataTable> 

然後支持我改變了我的代碼,這一點,但現在鏈接不走我到example.com。從我在interwebs上發現的內容來看,commandLink只能使用我認爲的EL表達式。

<p:dataTable var="inv" value="#{personBacker.investigators}" id="tbl" rows="50" effect="true"> 

     <p:column filterBy="#{inv.name}" headerText="Investigator" filterMatchMode="contains"> 
      <p:commandLink action="http://example.com" value="#{inv.name}" /> 
     </p:column> 

    </p:dataTable> 

我如何鏈接到使用H外部站點:commandLink或號碼:commandLink標籤?

回答

1

我不知道如果我的建議,將在您的設置與DataExporter工作,但調用從commandLink /的commandButton我使用一個外部鏈接,我設置了以下內容:

<p:commandLink value="external link" ajax="false" action="#{bean.externalLink()}" /> 

豆:

public void externalLink() throws IOException { 

    ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext(); 
    // call external link 
    String link = "http://www.google.com"; 
    ec.redirect(link); 
} 

另一種方法是試圖設置鏈接爲HTML -tag直接。這schouldn't太難爲你在你的代碼表明,該網址已經知道:

<a href="http://www.example.com">#{inv.name}</a> 

我希望這有助於,有樂趣!

+0

我試着直接在html中設置url,但dataExporter沒有正確處理。我會給你第一個建議一個鏡頭。 – Catfish 2012-03-23 13:10:47

相關問題