Sunday, June 14, 2015

Switcher in OAF

sometimes we may need to show different images for different rows based on some conditions
like in below image






let's see how to achieve it 
I want to show different images for a different records based on the status column if it is P one image and if its any thing else then another different Image

There is a region called switcher for this type of requirement in oaf

Right click on any table column select switcher 


















Row right click on switcher and add new case

Now right click on case add new item and change the property of it to desired like MessageStyledText, Choice, Image etc. In my case am using a Image 
Add as many cases as many conditions you have
if you have 3 conditions add 3 cases. In my case i have 2 conditions so i am adding two cases
write a Sql query that returns different values for different conditions like below

SELECT emp_id,
       full_name,
       date_of_birth,
       DECODE (gender,  'M', 'Male',  'F', 'Female') Gender,
       email_id,
       status,
       DECODE (status, 'N', 'Enabled', 'Disabled') Update_Enabled,
       marital_status
  FROM emp_master

My Query returns the value Enabled if status is N and Disabled for all other values

I am using the same query in the vo mapped to table

Now change the Id of the Items under case as per the values returned by query.

so give different images for Enabled Item and Disabled Item like in below image

now give the view attribute to Switcher item
here i have give UpdateEnabled as my view attribute because this columns holds the logic to give different values for different row based on the flag

Now write a code to execute query of the vo attached to table on process request then you can get the required output.

Different Image for different rows using this you can handle Update on few rows and disable on few rows.












No comments: