简体   繁体   English

如何为h:graphicImage Primefaces添加动作

[英]How to add action for h:graphicImage Primefaces

Hi I have a graphicalImage and I want a method in the backingBean to be fired up on clicking on the image.Below is the code snippet that i am using but it is not working. 嗨,我有一个graphicalImageImage,我希望在单击图像时触发backingBean中的方法。以下是我正在使用的代码段,但它不起作用。 Please help. 请帮忙。

<h:graphicImage value="../resources/images/delete_button.png"
onclick="editBean.deleteStudyPlan"
style="float:center;height: 18px; width:20px;"
title="Delete the studyplan"/>

You need to wrap it in a <h:commandLink> or <p:commandLink> and specify the action there. 您需要将其包装在<h:commandLink><p:commandLink>并在那里指定action

<h:commandLink action="#{editBean.deleteStudyPlan}">
    <h:graphicImage ... />
</h:commandLink>

Alternatively, you can just specify the image as a CSS background image of the command link or button. 或者,您可以仅将图像指定为命令链接或按钮的CSS背景图像。

The onclick surely isn't a method expression to a JSF backing bean action method. onclick当然不是JSF支持bean操作方法的方法表达式。 It's a JavaScript function handler. 这是一个JavaScript函数处理程序。 JavaScript is an entirely different language which runs in the webbrowser, working on the HTML code produced by JSF. JavaScript是一种完全不同的语言,可在Web浏览器中运行,用于处理JSF生成的HTML代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM