Tuesday, September 1, 2015

ADF 12c Dynamic Forms with ADF BC UI Categories

ADF 12c offers completely new way to implement UI forms. We can implement dynamic forms, based on static ADF BC components. Such approach could simplify form maintenance - when there will be changes in DB, developer would need to adjust only ADF BC EO/VO structure, without changing anything on UI. Bindings layers could determine data structure dynamically and dictate how to render UI blocks. ADF BC VO provides special metadata option to define how form UI should be rendered - UI Categories. Through categories we could group attributes and this would help to render dynamic UI with separate blocks and proper order.

Using UI Categories is straightforward, add category group and move attributes under the category. Label and tooltip can be defined, this will be a title for UI block:


ADF 12c is using general collection binding for dynamic UI, it doesn't depend on specific attribute binding:


Collection binding is generic, without a list of accessible attributes, it just points to the VO. This means we can change list of attributes registered in the VO at any time:


This is how looks dynamic form generated in ADF 12c. I have customised it a bit, but major part is generated automatically by JDeveloper 12c. There is global iterator over UI Categories, rendered UI blocks. Inner iterator renders UI Category attributes. Each attribute is rendered through ADF 12c dynamic component, this means there is no dependency related to attribute UI implementation (input text, LOV, choice list, etc.) - UI implementation is controlled from attribute UI hints in ADF BC:


It is easier to understand how dynamic form is organised from UI structure view:


This is the result - dynamic form is rendered with two blocks, based on defined UI Categories:


I have customised dynamic form rendering with metadata usage. Buttons are rendered only in the first block, identified by PersonalData:


Block identified by JobData is rendered with maximum 4 rows:


I hope this post will give you some new ideas about robust ADF UI implementation. Download sample application - ADFAltaApp_v7.zip.

20 comments:

Anonymous said...

Hi Andrejus,

This is a very useful feature in 12C.

But now since the components are rendered dynamically inside iterator using dynamicComponent tag, does this means we now can't use the various properties of the UI components which were earlier used to display attributes in form, like visible/render, binding,value and various other properties of say inputText component, which are helpful in achieving various functionality. Also the ADF faces validators can't be applied?

Thanks

Andrej Baranovskij said...

You can do all the things you describe through declarative component in 12c. It supports all properties of regular ADF Faces components. I mention this in the post.

Regards,
Andrejus

mariam said...

How are you Andrejus .... Hope you fine
I need your help for the following case:
The activity nature of the client is very dynamic
Need to have a dynamic form (he wants to create many form every day by himself in run time). And add some components in the run time.
He doesn't have a standard form so he need every day to create new form
For example he can make today a form with group of input text and group of check box and table and tomorrow he need to make a new form with input text and radio and table also etc..,.
In addition he needs to achieve and save it into database to use it and retrieve it later
So he want to save created form contains data saved in the database
And also he wants to arrange the component on the page by his own way
How could I do it?

Anonymous said...

Hi Andrejus,

This is wonderful piece of code for dynamic UI.

Also, is there way to customize the field order in the dynamic form.

Andrej Baranovskij said...

This example is based on dynamic ADF UI. Do you want to change order while rendering UI?

Andrejus

oracleadfecn said...

Yes, different order for different user.

Andrej Baranovskij said...

I dont have ready solution for this question, may be you could override categories implementation in ADF BC. I will need to check that.

Regards,
Andrejus

Anonymous said...

Category is one, but the order of the fields is different, Is there a way to over-ride the field order property. Field Order is displayed under schema properties in the XML

SQLType="NUMERIC">







Andrej Baranovskij said...

Should be possible. But I dont have example for your request.

Regards,
Andrejus

Anonymous said...

Where do you think I need to write code to over-ride field order.. should I try over-ride attribute hints... I see getFieldOrder.. I dont see a setFieldOrder.. Also is there a way write a groovy expression in VO source to read from resourcebundle.. Please do point a starting point. really appreciate your help in this, Most of our programming problems were solved by your blogs.

Andrej Baranovskij said...

I will take a look into that, is on my todo list.

Regards,
Andrejus

Anonymous said...

Thank you very much. Really appreciate it.

Anonymous said...

Hi Andrejus,

Did you get a chance to look into the filed order customization issue.

Thanks.

Andrej Baranovskij said...

Not yet, busy with questions from our projects. Its on my todo list, should be able to find time to solve it this or next week.

Regards,
Andrejus

Anonymous said...

Thank you very much.

Andrej Baranovskij said...

Hi,

It seems field order is coming from Attribute Definition. This means you can't have it different for each user, it must be same for all users.

If you want to control field order, you can do it from your own ADF BC attribute collection, managed in managed bean. See example in my other post: http://andrejusb.blogspot.lt/2014/11/adaptive-form-with-dynamic-adf-lov.html

Good luck with your project.

Regards,
Andrejus

Anonymous said...

Can we not have a groovy expresion on the FIELD_ORDER schema properties value in the source XML of the VO and that groovy expression could bind to app resource bundle hash map which has a numeric value to FIELD_ORDER?

Andrej Baranovskij said...

You should check it. It might be FIELD_ORDER is initialized only once per all session in definition object. If it works - good. Please check it and post update here :)

Andrejus

Andrej Baranovskij said...

If you want to reference dynamic value through Groovy, this post will be helpful - http://andrejusb.blogspot.lt/2016/04/adf-12c-custom-property-groovy-and.html It actually quite simple.

Andrejus

Anonymous said...

Looks interesting.. Let me try and will keep you posted.