X

Shay Shmeltzer's Oracle Development Tools Tips

Creating Dynamic ADF Input Forms with Iterator

Shay Shmeltzer
Director of Product Management - Oracle

I showed before how to use the dynamic tag library to create dynamic forms/tables that can show an unknown number of fields. While using those tags is very easy, they are meant for read-only data view. What if you actually want to create a page with input fields, but you don't know ahead of time how many fields will be needed?

Well here is a little solution.

It uses an array that lists the fields you'll want to show, and then an iterator in the page to run over this array and display the fields.

Application zip file is here.

And here is a short demo showing the form in action and explaining what is happening behind the scenes.

By the way, in the zipped version I added another button to the page that when pressed adds one more field to the form.

Join the discussion

Comments ( 15 )
  • guest Monday, February 20, 2012

    Hi Shay, how are you.

    I am just new for Oracle ADF, and I am starting to learn Oracle ADF, and your training session in Oracle official website provide me much more clear overview and direction about ADF.

    Now I have the requirements about troubleshooting the application which developed through Oracle ADF 10g and currently have two problems I need to figure out as following:

    1. The application is very slow while input data via ADF form.

    2. ADF 10g can not support IE8.

    Can you please point me at right direction for application checking? Thanks!


  • Shay Monday, February 20, 2012

    guest - These type of questions are better answered on the OTN JDeveloper discussion forum.

    While posting there you should probably mention what specifically is not working for you on IE8, and what specifically is slow in your form.


  • Roy Tuesday, February 21, 2012

    Hi Shay,

    Thanks for your response.

    Can you please post the reference post in JDeveloper forum?

    I did search, but not found available clue.

    Thanks.

    Roy


  • shay Tuesday, February 21, 2012

    Roy, the JDeveloper forum is here:

    https://forums.oracle.com/forums/forum.jspa?forumID=83

    You can register and post your own questions there.


  • Priya Monday, June 4, 2012

    Hi shay,

    In you sample you have shown dynamic fields as text and and date. is it possible to have List Of Values field also as dynamic and also to have the query for the LOV population also as a parameter in the Fields.java ?

    Thanks,

    Priya.


  • Shay Monday, June 4, 2012

    Priya, I would guess that it should be possible to add an LOV field in the same way. You'll probably need to provide more information in your bean about the field (for example the source of the model to the LOV) - but in term of creating the field in the screen it should work.


  • Priya Tuesday, June 5, 2012

    Hi Shay,

    Thanks for your response.

    As you said to have LOV fields also to be dynamic, I need to provide informations like the source of the model to the LOV. But that is where the challenge lies for me. I am looking for a way to create "listOfValuesModel" in java class, and I do not find any way for that. Is it possible to create ListOfValuesModel through java?

    Thanks,

    Priya.


  • Shay Tuesday, June 5, 2012

    Priya, the ADF Faces Components Demo has a screen that demos the LOV component

    http://jdevadf.oracle.com/adf-richclient-demo/faces/components/inputListOfValues.jspx

    and in the backing bean for that screen you'll see how to create the model for it in Java.

    Download it from here:

    http://www.oracle.com/technetwork/developer-tools/adf/documentation/adf-faces-rc-demo-083799.html


  • Vik Thursday, June 21, 2012

    Hey,

    Thanks for the example..really a great one...

    I have one question: you have added a method to add a field to the form..that just works for the first time...I think the new hash value is not getting set to the bean...can you help? Each time just one field remains..I need to add as many fields as user clicks the add button.

    Thanks


  • Ankit Shah Thursday, July 26, 2012

    Hi Shay,

    Great Post!!!

    I need to extend this functionality,as i have some requirement where i need to set the valueChangeEvent on one of the dynamically created component.Is there any where i can assign the different ID's to them ?

    Kindly suggest!!!


  • Shay Thursday, July 26, 2012

    Ankit, you should be able to call setValueChangeListener method on the component that you are creating and assign a pre-existing bean method to a specific field.


  • guest Thursday, August 9, 2012

    HI Shay

    Great example.

    One question where I need your help and guidance.

    Our business requirement changes over time and the form with its fields are subject to change over time (For example certain questions to be added on the form or disabled from the page over time)

    One of our requirement is to create a page(say X) where we define the labels and fields for another page (say Y).The definitions from page X will be stored in the database and page Y will be dynamically rendered through the definition details stored in the database from page X.

    For example,

    Page: Y

    Sequence:1

    Label: Company Name

    Field:comp_nm

    Enabled: Yes

    So if the user wants, user can disable the content in page X and then the next in sequence(in this example if sequence 1 company name is disabled, sequence2 will be rendered first) will be rendered in the page Y.

    Is there a way we can handle it through Dynamic form?

    I posted on the discussion forum, didnot get much headway.

    Thanks in advance.


  • Shay Thursday, August 9, 2012

    guest - you should be able to use the approach shown here and extend it to your case. Basically you'll have a method that retrieves all the fields that are to be rendered into an array - and then you iterate over that array and render the fields.


  • aalopez Friday, February 8, 2013

    Hi Shay, thanks for such great post. I have a question, I have my dynamic form in the same page as the button that executes the method in the AM. I'm not sure why, but I have to press the button twice in order to see the dynamic componentes... any ideas? Regards


  • aalopez Thursday, February 14, 2013

    Hi Shay, me again. I found the answer to my previous question, I'm posting it here maybe someone else needs it.

    https://forums.oracle.com/forums/message.jspa?messageID=10842306

    Regards.


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.