Wednesday, July 25, 2012

Switcher Component in ADF


The switcher component dynamically decides which facet component should be rendered. It has two properties. The switcher will render the facet matching "facetName"; however, if no such facet exists (or "facetName" is null), and "defaultFacet" has been set, then that facet will be used instead.

Steps:

1.Create VOs based on different tables in the Model Layer:
 



2. In View Controller, create a View Page .Drag a Panel Group Layout from the Component Palette onto the page.

3. Drag the Switcher component from the Component Palette into the Panel Group layout.

4.Right Click the af:Switcher component > Insert Inside af:Switcher > Facet



5.Provide a Name for the Facet. Create 2 Facets and provide corresponding names for both.




6.Drag the 'Dept' VO from the Data Controls onto the Facet with name 'Query1' and create a table using the VO.



7.Repeat the Step for 'Emp' VO and create the table in 'Query2' facet. The structure would look as the figure below :





8. Select the Switcher Component and change the DefaultFacet property to 'Query1'.




9.In the FacetName property of the Switcher, write #{requestScope.table}



 
10. Drag a 'Choice' component from the component palette before the Panel group layout .
Provide 2 static values (Facet Names that have been created earlier are taken as Item Values)in the create list tab as shown in the following figure.




11. Change the AutoSubmit property of the Select One Choice to 'true' and it's Value property should be set to #{requestScope.table} .

12. Also Provide PartialTrigger property of the Panel Group Layout with the id of the Select One Choice component.

13. Run the Page. When we select 'Query1' we get the Dept table(default) and on selecting 'Query 2', Emp table is displayed.