Friday, October 11, 2013

Adding Dynamic Columns to View Object in ADF BC

This post describes how we can add dynamic columns i.e columns at run time to the View Object.

The Application can be downloaded from Here.

Lets get started and create a simple ADF application say DynamicColumnExample. Create a new View Object and select it to be programmatic like below.

Add attributes like below.

Mark EmployeeName as Key Attribute and Finish.

Now Run the BC Tester and open the programmatic VO.

We can see that there are only two attributes which are defined at the time of creating VO.

Now lets create Impl and RowImpl classes for this programmatic VO.

Now create a new Method in AMImpl class. Below is the code for this method.

Add this method to client interface.

Now run the BC tester again.

If we open VO its still the same with two attributes.

Now double click on app module name .

Select the method name and provide values of the two dynamic columns to be added. Click execute.

Now again open the Programmatic VO.

Here you can see that two columns are added with values which we set in the method.

Also care should taken that there are two method provided by VO. These are addDynamicAttribute and addDynamicAttributeWithType.

If we use addDynamicAttribute , the type of added column is boolean by default and you can see a checkbox coming as value of column. So we need to use addDynamicAttributeWithType to make it of string type as textbox.

Happy Learning!!

1 comment:

  1. This is great! I've been trying to set the UI Hint label to these new attributes I'm creating on run time. Is there a way I can achieve this?