<h:inputText>
実行時にコンポーネントにajax 動作を追加しようとしています。次のコードで何がうまくいかないのかを理解するのに 1 日を費やしました。
メソッドを呼び出した後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);
}