Monday, November 21, 2011

Working With The Switcher Component.

This blog shows how we can use Switcher component. Switcher is used for conditional layout changes. For example, when used within a table, using switcher you can render different component for each row based on some values present in the rows. In this sample, I am using SCOTT.EMP table to render different images based on different 'Deptno' values for each emp row. The logic to use switcher is simple. A switcher contains with in it (one or many, based on the requirement) facets, and a switcher has a property called facetName which should point to the facet we want to render.

Here are the screen shots to explain this:

Fig 1:

The above figure shows that we want to render the facet whose name matches the value of Deptno for the current row.

Fig 2:

Since I know the Deptno has values like 10, 20, or 30, I have named the facet accordingly:

Fig 3:

Fig 4:

Fig 5:

The above 3 figure shows what we want to render in each facet.

Fig 6:

The above figure shows how the EmpView page looks like after adding the switcher.

Fig 7:

The above figure shows the output when the EmpView page is run.

No comments:

Post a Comment