识别在actionListener方法中单击的p:commandButton



我正在烦恼地在操作侦听器方法中获取单击的按钮 ID。

这是我的 xhtml 代码:

<p:commandButton id="submitButton" value="Delete" action="#{student.xxx()}"
                 actionListener="#{student.UserActionListener(e)}"/>

这是我的事件处理函数,我想在其中获取单击按钮的 id:

public void  UserActionListener (ActionEvent e) {
    System.out.println("the button id");
}

如何在操作侦听器方法中获取提交按钮的 ID?

use e.getComponent()

.......
import javax.faces.event.ActionEvent;
public class ........{
    public String buttonId; 
    public void  UserActionListener (ActionEvent e) {
        System.out.println(e.getComponent().getClientId());
    }
}

最新更新