Tuesday, December 8, 2015

Implementing Component Reference in ADF

There is a lot of confusion about how to use ADFcomponent binding in managed beans in a clustered environment to meet high availability.
UI Components are not serializable in ADF, so your application might fail to work correctly in a clustered environment.
So we need to implement Component Reference in backing beans .
This will be useful only in case of managed bean which is in a scope greater than requestScope or backingBeanScope.

Actual Backing Bean Bindings
-----------------------------------------------
    private RichCommandLink commandButton;

    public void setPagiCommand(RichCommandLink commandButton) {
        this.commandButton= commandButton;
    }

    public RichCommandLink getCommandButton() {
      
        return commandButton;
    }

ComponentReference Implementation
-----------------------------------------------
    private ComponentReference commandButton;


    public void setPagiCommand(RichCommandLink commandButton) {
        this.commandButton = ComponentReference.newUIComponentReference(commandButton);
    }

    public RichCommandLink getCommandButton() {
        if(commandButton!=null)
            return (RichCommandLink)commandButton.getComponent();
        return null;
    }

Thursday, July 9, 2015

Programatically Calling Hidden Button Action

If you want to call a hidden button action from another button action/event use below code

private void navigateByQueueAction() {
   FacesContext fctx = FacesContext.getCurrentInstance();
   UIViewRoot root = fctx.getViewRoot();
   //client Id of button includes naming container like id of region. 
   RichCommandButton button = 
           (RichCommandButton) root.findComponent("r1:cb3");
   ActionEvent actionEvent = new ActionEvent(button);
   actionEvent.queue();
}