Using af:switcher in ADF Faces to dynamically render page components

Sharing is Caring

Hello all,
Sometimes we need to display page components on a condition basis, this can be achieved in ADF using af:switcher component
Normally switcher component is a collection of multiple facets and on a given condition it decides that which facet should be rendered.

How to use af:switcher- see the steps

  • Create a Fusion web application and create business components using Departments and Employees table (HR Schema)
  •  Now create a page in view Controller and drop a switcher component from the component palette
    • The switcher is pure server-side component so it doesn’t have any client representation, so next move is to add facets in af:switcher, to add facets in the switcher,
      just right click–insert inside af:switcher– facet

  • As in this tutorial, I am going to show 2 tables(Departments U& Employees) so added 2 facets in the switcher

 

  • Now time to drop tables in corresponding facets, Employees Table in Emp, Departments Table in Dept
af:switcher
  •  Now I have created a static List that has values D for Departments and E for Employees, when the user selects D the Departments table will be shown and for E Employees table will be shown

 

  • to do this select af:switcher and go to FacetName property and open expression builder to write a conditional expression
  •  Now run this page and select values in the list to see- how switcher works

 

Download Sample App

Cheers 🙂 Happy Learning

Related Posts

0 thoughts on “Using af:switcher in ADF Faces to dynamically render page components”

  1. " Now i have created a static List that has values D for Departments and E for Employees, when user selects D the Departments table will be shown and for E Employees table will be shown"

    how did you get to this part?

  2. I have added a expression in FacetName property of af:switcher that expression checks selected value in choice list and returns corresponding FacetName
    I think you missed this step , Read again it is mentioned in post itself

    Ashish

Leave a Reply

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