如何在单击 p:graphicImage 时触发 ajax 事件侦听器?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10963171/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to trigger an ajax event listener on click of p:graphicImage?
提问by user1433804
I want to do some processing when the user click on the p:graphicsImage inside a ui:repeat How do i do it.
我想在用户单击 ui:repeat 中的 p:graphicsImage 时进行一些处理,我该怎么做。
<ui:repeat id="repeat" value="#{getData.image}" var="imageLst" varStatus="loop">
<h:panelGroup>
<p:graphicImage id="gi1" value="#{imageStreamer.image}" alt="image not available" >
<f:param name="id" value="#{imageLst.imageID}" />
<p:ajax id="aj2" event="click" listener="#{getData.searchID}" immediate="true" update=":form:tabView:check :form:growl"/>
</p:graphicImage>
</h:panelGroup>
</ui:repeat>
In the above code if i place the ajax part doesn't get triggered. How do i monitor a Click on the 'p:graphicImage'
在上面的代码中,如果我放置 ajax 部分不会被触发。我如何监控“p:graphicImage”上的点击
回答by BalusC
The <p:graphicImage>doesn't support any ajax events.
在<p:graphicImage>不支持任何AJAX事件。
Just wrap it in a <h:commandLink>(or the p:one).
只需将其包裹在一个<h:commandLink>(或p:一个)中。
<h:commandLink>
<p:graphicImage id="gi1" value="#{imageStreamer.image}" alt="image not available" >
<f:param name="id" value="#{imageLst.imageID}" />
</p:graphicImage>
<p:ajax id="aj2" listener="#{getData.searchID}" update=":form:tabView:check :form:growl"/>
</h:commandLink>

