I highlight the tricky parts I was not correct in the first place.
HtmlCommandButton b = new HtmlCommandButton();
AjaxBehavior ajax = new AjaxBehavior();
List<String> exs=new LinkedList<String>();
I highlighted three parts.
- First, give the button an ID explicitly. This may be a bug in JSF RI implementation. if you want to know more, go here.
- Second, the ajax "execute" attribute should include "@this". "@this" keyword informs the server that it should process the button and issues action event to this button. Otherwise, any event listener including ajax event listener will not be called.
- Third, attach the ajax vehavior to button as b.getDefaultEventName() which is "action". I first attached it as "click". "click" is a client-side event name. The logic event name for action is "action", not "click". This is automatically if xhtml file is used.