Invoking Button Action Programmatically,Queue Action Event in ADF

Sharing is Caring

Sometimes we need to invoke any button’s action in bean without pressing that button,
as you have to call button action on any component’s value change Listener- So how to do this in ADF managed bean.
ADF provides facility to queue action event one after another, means you can perform multiple actions by queueing

I am using bounded task flow with page fragments(.jsff)

    • Create a button in page fragment and define ActionListener in the managed bean
    • Now I have created an input text and its valueChangeListener in the managed bean
    • I wish to call button’ ActionListener in my input text valueChangeListener.

    • we can do this by writing this code snippet on valueChangeListener 
public void callAceVCE(ValueChangeEvent vce) {
if (vce.getNewValue() != null) {
//Code to call ActionEvent
FacesContext facesContext = FacesContext.getCurrentInstance();
UIViewRoot root = facesContext.getViewRoot();
/**Pass cb1(buttonId) if page is not in taskflow, else if page is inside region then pass rgionid:buttonId*/
RichCommandButton button = (RichCommandButton)root.findComponent(“r1:cb1”);
ActionEvent actionEvent = new ActionEvent(button);
actionEvent.queue();
}
}

 

  • Now run your page and when you will change input text value the queued button actionListener will be called
Cheers 🙂 Happy Learning

Related Posts

I’m an Oracle ACE, Blogger, Reviewer,
Technical Lead working on Oracle ADF

3 thoughts on “Invoking Button Action Programmatically,Queue Action Event in ADF”

Leave a Reply

Your email address will not be published. Required fields are marked *