Please disable your adblock and script blockers to view this page

Search this blog

Monday, 1 February 2016

ADF Basics: Using setActionListener in ADF, Set pageFlowScope parameter without writing code

This post is about using setActionListener tag in ADF, this tag provides a simpler way to set values of other objects and makes use of EL
See What docs says-

The setActionListener tag is a declarative way to allow an action source (<commandButton>, <commandLink>, etc.) to set a value before navigation. It is perhaps most useful in conjunction with the "pageFlowScope" EL scope provided by ADF Faces, as it makes it possible to pass details from one page to another without writing any Java code. This tag can be used both with ADF Faces commands and JSF standard tags. More generally, it can be used with any component at all that implements the standard ActionSource interface.


It has two properties

from Object Yes the source of the value; can be an EL expression or a constant value
to Object Only EL the target for the value; must be an EL expression

See how to use this component to set pageFlowScope parameters without writing any code

  • Created a Fusion Web Application using Employees table of HR Schema 

  • Created a bounded taskFlow and two page fragments in view controller project


  • Added two input parameters in BTF to hold Employee's First and Last Name


  • Dropped Employees View Object as form on page with navigation buttons and added one more button to navigate to second page after setting Employee's First and Last name in BTF input parameters


  • See the source of Go To Second Page button, dropped two setActionListener component under button to set First Name and Last Name. Here you can see from and to values of setActionListener, it does the job of setting pageDef values to BTF parameters

  • <af:button text="Go To Second Page" id="b1" action="goToSecondPage"
                               inlineStyle="font-weight:bold;color:red;">
                        <af:setActionListener from="#{bindings.FirstName.inputValue}" to="#{pageFlowScope.FIRST_NAME}"/>
                        <af:setActionListener from="#{bindings.LastName.inputValue}" to="#{pageFlowScope.LAST_NAME}"/>
                    </af:button>
    

  • In Second fragment added an output text that shows values of both BTF input parameters

  • <af:outputText value="#{pageFlowScope.FIRST_NAME}#{pageFlowScope.LAST_NAME}" id="ot1"
                       inlineStyle="font-size:medium;color:navy;font-weight:bold;"/>
    

  • All done :) Run and check application 

  • On First Page see Employee detail-

    On Second Page -

Sample ADF Application- Download
Cheers :) Happy Learning

No comments :

Post a Comment