作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试在 <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/
因为我问过 my last question (仍然没有回答)我继续寻找解决方案,最后我找到了 this topic我认为这可以帮助实现我想要的。 所以,我尝试了该解决方案(这本身就是一种解决方法),
我正在尝试在 中添加一些 ajax 行为运行时的组件。我花了一天时间弄清楚下一段代码出了什么问题,但没有成功。 调用 initUIComponent 后方法,组件确实触发了ajax请求,也返回了正常
我有一个函数,可以在 onload() 方法中将一些 javascript 附加到 AjaxRequestTarget。 我加载它 add(onload); onload 的代码如下 AjaxEven
我是一名优秀的程序员,十分优秀!