如何使用参数实现图像重定向?

时间:2013-03-29 16:24:29

标签: jsf jsf-2 graphicimage

这是commandButton实现带参数重定向的方式。

<h:commandButton value="Check" action="#{GetInfoBean.getInfo}">
<f:param name="ID" value="4"></f:param>
</h:commandButton>

点击此commandButton后,它会传递名为ID的参数,其值为4。托管bean GetInfoBean的方法getInfo()将返回新的URL。

但是现在,我的问题是如何使用imagegraphicImage实现此重定向流程,因为它没有action属性?

1 个答案:

答案 0 :(得分:3)

使用<h:commandLink>包裹图像:

<h:commandLink value="Check" action="#{GetInfoBean.getInfo}">
    <f:param name="ID" value="4"></f:param>
    <h:graphicImage value="/your/image.png" />
</h:commandLink>