Search This Blog

Loading...

Wednesday, June 22, 2011

ADF: Call custom JavaScript method during ADF component initialization

If you need to invoke custom Java Script method during some specific UI (ADF Faces) component initialization, then this post is for you. Idea is to useClientListenerSet::addBehavior(javax.el.ValueExpression) to associate a deferred value expression (referring a JavaScript method) with the UI component, which will be evaluated later when DOM is rendered on the page. 



public void
setSomeInputField(RichInputText inpField) {
   
this.inputField = inpField;
   

    ClientListenerSet clientListenerSet = inputField.getClientListeners();
  

    if (clientListenerSet == null) {
       clientListenerSet =
new ClientListenerSet();
       clientListenerSet.addBehavior("new CustomCompBehavior()");
       inputField.setClientListeners(clientListenerSet);
  }
}