gpt4 book ai didi

java - 在运行时添加 AjaxBehavior 但未调用 AjaxBehaviorListener

转载 作者:行者123 更新时间:2023-11-29 09:05:27 24 4
gpt4 key购买 nike

我正在尝试在 <h:inputText> 中添加一些 ajax 行为运行时的组件。我花了一天时间弄清楚下一段代码出了什么问题,但没有成功。

调用 initUIComponent 后方法,组件确实触发了ajax请求,也返回了正常的ajax响应。然而,AjaxBehaviorListener 永远不会被调用。我错过了什么?我使用带有默认 mojarra 实现的 glassfish 3.1.2.2。

public void initUIComponent(HtmlInputText c) {
FacesContext fc = FacesContext.getCurrentInstance();

AjaxBehavior ajaxBeh = (AjaxBehavior) fc.getApplication() .createBehavior(AjaxBehavior.BEHAVIOR_ID);
ajaxBeh.setRender(Collections.singletonList("elId1"));
ajaxBeh.setExecute(Collections.singletonList("@this"));
ajaxBeh.addAjaxBehaviorListener(new AjaxBehaviorListener() {
@Override
public void processAjaxBehavior(AjaxBehaviorEvent e)
throws AbortProcessingException {
System.out.println("Something is happening!");

}
});
c.addClientBehavior("keyup", ajaxBeh);

}

最佳答案

最后看来这是一个 Mojarra 错误。该代码可以与 MyFaces 一起顺利运行。 Here是相关的 Jira 问题 (JAVASERVERFACES-2674)。

关于java - 在运行时添加 AjaxBehavior 但未调用 AjaxBehaviorListener,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15299354/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com