2012-11-07 38 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

你能告诉我如何从中的远程位置访问图像吗? –