ajax 如何使用 AjaxBehaviorEvent 获取 selectedDate?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13890684/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-06 10:53:58  来源:igfitidea点击:

How to get selectedDate using AjaxBehaviorEvent?

ajaxjakarta-eeprimefaces

提问by Arunprasad

<h:outputLabel id="remainingDays" value="#{bean.DueDate}" title="#{bean.remainingDays}"  >
<p:ajax listener="#{bean.listenerMethid}" update="remainingDays,remainingDays" process="remainingDays" event="mouseover"></p:ajax>
</h:outputLabel>
<p:tooltip for="remainingDays" id="tooltip" />



public void listenerMethod(AjaxBehaviorEvent event){


}

How can i get Duedate using AjaxBehaviorEvent inside the listenerMethod()

如何在 listenerMethod() 中使用 AjaxBehaviorEvent 获取 Duedate

回答by grekier

This should work as a general way to get the value through AjaxBehaviorEvent:

这应该作为通过 AjaxBehaviorEvent 获取值的一般方法:

public void listenerMethod(AjaxBehaviorEvent event) {
    String dueDate = (String) ((UIOutput)event.getSource()).getValue();
}

However, in your case, you can just access it through the varable (or getter) since it is in the same bean as the listenerMethod.

但是,在您的情况下,您可以通过变量(或 getter)访问它,因为它与 listenerMethod 在同一个 bean 中。