2012-11-07 37 views
2

我使用h:graphicImage來使用name屬性顯示圖像。現在,爲了成功實現PrettyPhoto (JQuery implementation),我需要得到的圖像路徑(/javax.faces.resource/pictures/file.png.xhtml)也與我的<a href />一樣。h:graphicImage的路徑圖像JSF

正如你可以從PrettyPhoto文檔的摘要中看到的,我需要的路徑,我的形象,我<a href />路徑(實際上有區別,由於使用縮略圖的事實):

<a href="images/fullscreen/2.jpg" rel="prettyPhoto" title="This is the description"> 
    <img src="images/thumbnails/t_2.jpg" width="60" height="60" alt="This is the title" /> 
</a> 

有什麼辦法可以爲我的h:outputLink提取resourceName(因爲它的名字是h:graphicImage)?

回答

11

您可以使用隱式EL變量mapper #{resource}將JSF資源庫/名稱轉換爲完整的URL。

所以,你的具體情況,

<h:outputLink value="#{resource['images/fullscreen/2.jpg']}"> 
    <h:graphicImage name="images/thumbnails/t_2.jpg" /> 
</h:outputLink> 

如果您還使用資源庫,那麼語法應該像如下:

<h:outputLink value="#{resource['default:images/fullscreen/2.jpg']}"> 
    <h:graphicImage library="default" name="images/thumbnails/t_2.jpg" /> 
</h:outputLink> 

(請注意,你甚至可以只使用<a href>代替<h:outputLink value>

+0

太棒了,正是我在找的東西。再一次感謝你! – Aquillo

+0

不客氣。 – BalusC

+0

你能告訴我如何從中的遠程位置訪問圖像嗎? –