[英]Path to image by h:graphicImage JSF
我正在使用 h:graphicImage 使用name
属性显示图像。 现在,为了成功实现PrettyPhoto (JQuery implementation) ,我也需要图像的结果路径 ( /javax.faces.resource/pictures/file.png.xhtml
) 作为结果在我的<a href />
。
正如您从 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
命名)?
您可以使用隐式 EL 变量映射器#{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>
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.