Thursday, October 28, 2010

ADF UI - How to specify actionlistener for train buttons (i.e., 'Back' and 'Next' buttons in <af:trainButtonBar>)

The most common requirement for the applications that use ADF train component is to specify the actionlistener for the train navigation buttons 'Back' and 'Next'. But, generally we use <af:trainbuttonbar> to render 'Back' and 'Next' buttons which doesn't have the property 'actionListener'. So, here I'll show to achieve the same 'Back', 'Next' train navigation using normal command buttons or command toolbar buttons so that we can specify action listener and other properties like 'immediate' to supress validations on clicking 'Back' or 'Next' buttons.

Just use the below code instead of <af:trainbuttonbar> in your page to achieve the same navigation effect along with the properties you require from the commandButton.

<af:commandButton id="back" text="Back" action="#{controllerContext.currentViewPort.taskFlowContext.trainModel.getPrevious}" immediate="true"/> <af:commandButton id="next" text="Next" action="#{controllerContext.currentViewPort.taskFlowContext.trainModel.getNext}" immediate="true"/>

Here, we're actually getting trainModel from trainFlowContext and navigating back and forth using 'getPrevious' and 'getNext' methods. That's it! Enjoy :) !


  1. Tanks for this information. It's exactly what I'm looking for...

  2. Yes i wanted this immediate too. My first approach was to get the children of af:trainButtonBar through binding in a bean. And set immediate in the bean for the back button. But surprisingly it has 0 children using getChildren.

    Thanks Anyways

  3. where did you get this getPrevious,getNext method define


Related Posts with Thumbnails