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;
    }