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
How to get selectedDate using AjaxBehaviorEvent?
提问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 中。

