6

我正在使用<p:graphicImage>如下:

<div id="mapp">
    <h3>Country Map</h3>         
    <p:graphicImage id="city"
                    value="#{countryPages_Setup.countryMap}"
                    width="250"
                    height="190">

     </p:graphicImage>                
</div>

但这不是可点击的图像。我怎样才能使这个图像可点击,所以当用户点击它时,我可以调用我想要的托管 bean 操作。

4

2 回答 2

18

将图像包装在h:commandLink/中h:link

<h:commandLink action="...">
  <p:graphicImage id="city"
            value="#{countryPages_Setup.countryMap}"
            width="250"
            height="190">
  </p:graphicImage>
</h:commandLink>
于 2012-03-29T11:57:22.800 回答
1

如果 p:graphicImage 在 ap:contentFlow 内,您可以使用以下内容:

对我来说,这非常有效:

<h:form id="imageFlowForm">
    <p:contentFlow id="imageContent" value="#{controller.allImages}" var="entry">
        <div class="caption">#{entry.name}</div>
        <p:commandLink styleClass="content" action="#{controller.doAction}" update="detailForm">
            <p:graphicImage value="#{entry.imagePreviewUrl}" styleClass="content" width="50px" />
            <f:param name="id" value="#{entry.id}" />
        </p:commandLink>
    </p:contentFlow>
</h:form>
于 2015-12-04T13:29:58.483 回答