X

Shay Shmeltzer's Oracle Development Tools Tips

  • October 22, 2010

ADF Faces Dynamic Tags - For a Form that Changes Dynamically

Shay Shmeltzer
Director of Product Management - Oracle

I think this is one of the hidden gems of Oracle ADF - a set of components that can display different data each time.

There is a dynamic form and a dynamic table, both read the meta-data of the component you want them to display and create JSF components on the page to show those at runtime.

The following demo shows the basics of how to use them.

We are creating a method in our Application Module that changes the definition of a view object to be based on a provided SQL statement.

Then we bind that VO to our page using the dynamic Form component.

And voila - you'll give the SQL, we'll show the data...

Two notes:

The vo.executeQuery call in the AM method is redundant in this case. The view will be queried when you navigate to the page without this call also.

Dragging a data control as a dynamic table should result in a code that looks like this in our JSF:

If it doesn't make sure you dropped the right dynamic table. You'll see two options in the drop menu with similar name.You need to choose the "ADF Dynamic Table" one.

Join the discussion

Comments ( 35 )
  • Martin Saturday, October 23, 2010
    Very impressive example.
    Thank you!
    Martin
  • Estefanie Canseco Monday, October 25, 2010
    Thank you very much!
    I have a question: If I use a dynamic table instead of a dynamic form how can I select a row and take that value?
    Thanx for all
  • shay.shmeltzer Tuesday, October 26, 2010
    While it would probably not be as trivial as you can achieve with a normal table, the selectionListener on a dynamic table can still be invoked - and in it you can code your parameter passing.
  • Estefanie Canseco Wednesday, November 10, 2010
    Hi Shay:
    Thank you for all your help.
    The dynamic solution worked fine, but I did not use the dynamic table. It was to messy for me.
    Now I have a different issue: I tried to refactor (change the name) of my aplication module because my client didn't want to keep deafult name (AppModule) and JDeveloper dont do it !!! Can you tell me please if this is a tool bug or simply it can't be done?
    Thank you again for your support!!!
  • shay.shmeltzer Wednesday, November 10, 2010
    Estefanie, I think you are running into bug 9134982 - which is marked as fixed in the next patchset for JDeveloper.
  • Estefanie Canseco Thursday, November 11, 2010
    Oh thank you Shay you save my life once again and I have another question: Is it possible to change the default error messagges that JDeveloper show from DataBase? I have to show a custom messagge for the end-user that a composed primary-key is needeed but I cant change de DataBase messagge.
    Thank you again for your help!!
  • shay.shmeltzer Thursday, November 11, 2010
    Estefanie, customizing error messages including the ones from the DB is covered in the Fusion Developer Guide
    http://download.oracle.com/docs/cd/E14571_01/web.1111/b31974/bcadvgen.htm#BABEFGCI
  • Estefanie Canseco Thursday, November 11, 2010
    Thank you very much Shay I promise to send you a StarBucks coffee :P
  • sunil Monday, November 29, 2010
    hi shay,
    its a really nice example and which minimize my effort in building dynamic UI, i would be more interested in building an editable UI. Could you please provide some pointers how to build such UI and also i am concerned about the components used in a form layout or a table layout like we are more interested to use choice lists, LOVs rather than simple input texts.
    please help us with this.
    Thanks,
    Sunil.
  • Dario Toginho Monday, January 17, 2011
    hi shay,
    its a really nice example and which minimize my effort in building dynamic UI.
    But I am need your help to use this example in a just page fragment ou page, without call another task.
    How can I do that?
    Please help us with this.
    Thanks,
    DOT
  • shay.shmeltzer Tuesday, January 18, 2011
    Dario, this should basically be the same - you just need to find the right locaiton to write the code that defines the VO - could be button on the page before the page you are showing, could be a phase listener, and could be a method call.
    Frankly I think using the taskflow approach is best and the clearer way to do this - if you are using a page fragment - it should be inside a taskflow in any case, and then you just add the method call to that taskflow.
  • ILya Cyclone Thursday, March 10, 2011
    Hi Shay,
    Thanks a lot for your example.
    That makes me ask you a question - while acquiring SQL programmatically and using dynamic table can I customize column filters (replace inputText with selectOneChoice) and set column width/stretchColumn?
  • guest Sunday, June 19, 2011

    hi shay, we are also interested about editable dynamic form, would you provide some examples? thanks.


  • Shay Monday, June 20, 2011

    Guest - for an editable form you'll need to have a VO that is updateable - either by being based on EO or creating a programmatic VO.


  • guest Wednesday, August 3, 2011

    Hi Shay,

    I've followed your example step by step, but when I drop the form from the datacontrol panel onto a jsf page, in the drop box list which appears there's no dynamic form to choose - and yes I did added the dynamic form tag library.

    Any suggestion ? I'm running JDeveloper 11g Rel. 2.

    Thanks,

    Sergio.


  • sergio Wednesday, August 3, 2011

    Hi,

    I've solved the issue with dynamic form not shown in the drop list - I had to choose a jspx page and not a jsf facelet.

    A question though: how can I call the dynamic form when I click on a table element ?

    I try to explain better: I have a table from within different databasetable names appear. I want to click on a table element, get the table name from the clicked row cell, and with that table name, run the dynamic table. Would that possible ? If so, could you explain how to achieve that ?

    By the way, very interesting tutorial. Keep on please ;-)

    Regards,

    Sergio.


  • guest Tuesday, August 9, 2011

    hi shay,

    can you advise on how to implement usage of createViewObjectOnRowSet()

    instead of createViewObjectFromQueryStmt?

    I intend to implement dynamic table on PlSql procedure with Cursor Out param.

    ------------------------------------------

    import java.sql.ResultSet;

    ResultSet rset;

    ....

    rset=((OracleCallableStatement)cst).getCursor(3);

    vo=this.createViewObjectOnRowSet("v1", (oracle.jbo.RowSet)rset);

    //here runtime error occurs

    --------------------------------------------

    The problem to call vo=this.createViewObjectOnRowSet("v1", (oracle.jbo.RowSet)rset);

    is about RowSet proper cast.

    -------------------

    Best regards,

    Alex Bondarenko


  • shay Tuesday, August 9, 2011

    Alex - you might want to read 42.8.4 How to Create a View Object on a REF CURSOR

    http://download.oracle.com/docs/cd/E16162_01/web.1112/e16182/bcadvvo.htm#CEGIDAJA


  • ebox999 Wednesday, August 10, 2011

    hey Shay,

    that is regarding implementing dynamic table on ref cursor.

    thank you for the link, it means i've started to dig in the right way, in parallel.


  • guest Wednesday, February 15, 2012

    Hi Shay,

    Thanks a lot for the post.

    I followed the same procedure and I could create a dynamic read only form. Now, I would like to create a read and write form. That is, the form should be editable and it should post the updated data into the database.

    Please help.


  • Shay Thursday, February 16, 2012

    guest, for a read/write form you'll need to use another approach - check out this sample/blog - https://blogs.oracle.com/shay/entry/creating_dynamic_adf_input_forms


  • guest Friday, August 31, 2012

    Hi!

    I have some questions:

    1) When I use makeVO from Your example and generate dynamic table then this table always is read only and I can't insert data using CreateInsert operation. What I need to do to resolve my problem?

    2) If I have method parameter displayed in form like input field with value: #{bindings.st.inputValue}, how can I say that this value is 180 or read this parameter from other tables row?

    3) How can I read value from created dynamic table selected row?

    Hope for Your answer soon, regards, Kristaps


  • Shay Wednesday, September 5, 2012

    guest - I don't think the dynamic components will answer your need to do an update or select a record.

    For those have a look at the forEach based solution shown here:

    http://jobinesh.blogspot.com/2010/06/model-driven-approach-for-building.html

    For question 2 - you can set the NDValue of a parameter in the binding tab to point to any EL you need it including #{'180'}


  • Manish Pandey Tuesday, December 25, 2012

    Hi Shay,

    when i create ADF Dynamic table in jspx page it is running fine. but when i create it on jsff page as bounded task flow and drag task flow in jspx page as region it given

    java.lang.NullPointerException at oracle.adfinternal.view.faces.dynamic.DynamicForm.isRefreshNecessary(DynamicForm.java:503).

    what is the problem i don't understand. please help me.


  • Michael Shapira Thursday, February 14, 2013

    I used your post to create dynamic: table from dynamically created VO.

    However the table I got doesn't has sorting or filtering option. How can it be achieved


  • Shay Thursday, February 14, 2013

    Michael, there is no built in support for sorting since we don't know the structure behind the table. There is however a sortListener on the table - so you should be able to code logic there that will add the sort to your VO and re-execute it. I'm not sure if it will change anything but depending on your use case maybe using the "read only dynamic table option" will make it simpler to implement since you have a column object there.


  • guest Thursday, June 6, 2013

    Shay,

    I am working on a generic file upload utitlity, and I keep getting the error:

    java.lang.NullPointerException

    at oracle.adfinternal.view.faces.dynamic.AttributeHelper.getFilteredAttributeDefinitions(AttributeHelper.java:60)

    this only happens when i add the row the VO using NameValuePairs and createandInitRow function. If I createrow and insertrow it works fine.

    However in the second case I dont get the Entity validations.

    Please advice. (i am working with jdev11.1.1.7.0)

    Thanks

    Anand


  • guest Monday, June 10, 2013

    Hi Shay,

    I've created a table with max 6 columns.. Its width is fixed as 90% in CSS file. But when an action takes place like "view only 4 columns" then the extra space is visible.. I want the width of the table to be dynamic according the number of rows I select. Can you please help me with this problem..?


  • guest Thursday, June 13, 2013

    Hi Shay,

    There is panelcollection, inside which am using a table. I've fixed the width of the table in css for max number of columns I want to show. But if the number of columns reduce, extra white space is visible. The width of the table should be dynamic according to the number of columns chosen. Can you please help me with this.

    Thanks.


  • guest Friday, March 21, 2014

    Hi Shay,

    I've to create a page wherein user can enter the query and get the results of the query on the click of an Execute button as you've done here and it has helped me a lot!

    I've used createViewObjectFromQueryStmt to create a view object dynamically and implemented a method in my AM that implements this functionality.

    I'm getting the results in a dynamic table and displaying them on the page.

    But now, i've both the query text box and the table on the same page and i'm having problems in firing multiple queries. The result of first query is displayed perfectly but the second query doesn't fetch any results. The dynamic table still shows attributes from the previous query and doesn't show the new attribute defs related to the new query.

    Eg. If i fire select * from EMP; The results are populated into the table perfectly.

    But now I fire select * from dept; It shows an error that Emp no. returned NULL, which is an attribute of the EMP table and not department. It still searches for old attribute defs in the new table.

    Any help would be highly appreciated.

    Thanks.


  • Devendra Friday, March 21, 2014

    Hi,

    i facing problem in calling web service programmatically, I follow all steps of weather app which is available on net,and i create web service over jdeveloper call this by creating web service data control and accessing it in bean using function invokeDataControl.but both times it return me null value in generic type object,

    do you have any solution for this.


  • guest Tuesday, March 25, 2014

    guest - it depends on what you are actually refreshing You might need to refresh the containing layout component in which the table is - I haven't tried both on the same page.


  • guest Wednesday, July 2, 2014

    I have replicated same thing as shown in the video but i am getting following error:

    "Definition Dummy of type Attribute is not found in v1".

    Any help would be highly appreciated.


  • David Gress Friday, June 17, 2016

    How can I get a commandLink as a column using af:dynamicComponent?

    Thanks!


  • Shay Shmeltzer Friday, June 17, 2016

    David - you can't do this with this component - you could use another approach for creating dynamic UI for example: https://blogs.oracle.com/shay/entry/creating_dynamic_adf_input_forms


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