-
1. Re: How to add a4j:ajax onblur programmatically in richfaces 4
eunnini Jun 23, 2011 5:28 AM (in response to eunnini)Hello,
I've found a solution
public HtmlInputText createAjaxInput() {
HtmlInputText input = (HtmlInputText) FacesContext.getCurrentInstance().getApplication().createComponent(HtmlInputText.COMPONENT_TYPE);
AjaxBehavior ajaxBehavior = (AjaxBehavior) FacesContext.getCurrentInstance().getApplication().createBehavior(AjaxBehavior.BEHAVIOR_ID);
MethodExpression listener = FacesContext.getCurrentInstance().getApplication().getExpressionFactory()
.createMethodExpression(FacesContext.getCurrentInstance().getELContext(), "#{helloBean.inputAction}", null, new Class[] { BehaviorEvent.class });
ajaxBehavior.addAjaxBehaviorListener(new MethodExpressionAjaxBehaviorListener(listener)); input.addClientBehavior("keyup", ajaxBehavior);
input.addClientBehavior("blur", ajaxBehavior);
return input;
}
Regards