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 :) !

6 comments:

Related Posts with Thumbnails