This discussion is archived
1 2 Previous Next 18 Replies Latest reply: Jul 26, 2013 12:46 AM by 986494 RSS

How to refresh the Table of a parent windows after closing child window.

986494 Newbie
Currently Being Moderated

Hi Team

 

My application has one af:table with a button in one of its columns (one button for every row). The table is bind to a VO.

 

When clicking on this button(command Button), a new window gets open with some process. This process modifies information in the DB that is shown by the parent table.

 

After updating the information the popup opens with a message (Data Saved Sucessfully) and a Command button OK is present in the popup.

 

I would like the parent table information to be refreshed automatically when the child window closes in order to see the changes done by the child window.

 

I m using Jdev 11.1.1.4

 

Thanks

Zoran Cena

  • 1. Re: How to refresh the Table of a parent windows after closing child window.
    Timo Hahn Oracle ACE
    Currently Being Moderated

    Put an action Listener on the ok button. In the action listener you execute the parent iterator. that should be enough to see the new or change data.

     

    Timo

  • 2. Re: How to refresh the Table of a parent windows after closing child window.
    986494 Newbie
    Currently Being Moderated

    Hi Timo

     

    Thanks for the Quick response. But my concern is ..... the confirmation popup comes on the new window and on clicking on ok button the window (Child Window) should close as well as refreshes the parent page table. this is what i m looking for solution.

     

    P.S - I have tried the method you have suggested. But it throws the null pointer exception. Becouse the iterator is not in the second page (new window). It is in the parent page only.

     

     

    Thanks

    Zoran Cena

  • 3. Re: How to refresh the Table of a parent windows after closing child window.
    codigoadf Oracle ACE
    Currently Being Moderated

    Hi,

    if the parent and child are in differents taskflows you can use parent action activities

    see Working with Task Flow Activities

  • 4. Re: How to refresh the Table of a parent windows after closing child window.
    986494 Newbie
    Currently Being Moderated

    Unfortunately, both pages are in the same task-flow (Un-bounded) !!.

     

     

    Thanks

    Zoran Cena

  • 5. Re: How to refresh the Table of a parent windows after closing child window.
    Dimitar Dimitrov Expert
    Currently Being Moderated

    How do you open the child window? If you open it as a dialog using the ADF Dialog Framework (e.g. by a "dialog:<xxxxxx>" page outcome), then you can configure a ReturnListener in the command button in the parent page (this one that opens the child window). The ReturnListener will be invoked when the dialog window is closed. There you should re-execute the table's VO and refresh the table component by PPR programmatically (e.g. by invoking AdfFacesContext.getCurrentInstance().addPartialTarget(<the-table-component>).

     

    Dimitar

  • 6. Re: How to refresh the Table of a parent windows after closing child window.
    986494 Newbie
    Currently Being Moderated

    Hi Dimitar

     

    Thanks a lot for your post. this is exactly the same situation is ....... J

     

    I m able to refresh the table.

     

    But still there is one situation where it fails. The scenario is like when i try to update any new data (After clicking on update icon and opening of new window then clicking of Popup OK button which closes the window) the table doesn't gets refreshed. The only thing is when I try to update the existing record. The table refreshes. Is there something that we can do in order to refresh this properly from both of the scenarios.

     

    Thanks

    'Zoran Cena

  • 7. Re: How to refresh the Table of a parent windows after closing child window.
    Dimitar Dimitrov Expert
    Currently Being Moderated

    Your use case is not quite clear to me. What I have understood so far is that you have a page featuring an editable table based on an updateable VO and you need to refresh some attributes of the current VO row when the "Update" dialog is closed, because the dialog's processing may have changed some data directly in the DB and the VO row contains old values. From your last post above I realized that you might have got also new (uncommitted) rows in the parent VO and you could open the "Update" dialog for new VO rows too.

     

    If it is so, then you should not refresh the VO row attributes by re-executing the VO's query or by invoking Row.refresh(...), because a new row is not-existing in the DB, so it cannot be requeried/refreshed. You should implement a different strategy:

    • Create a custom VO row client method that retrieves the necessary values through direct JDBC calls (e.g. through PreparedStatements) and populates the values programmatically into the corresponding VO row attributes. (Hint: If the attributes are Entity-based, you can use the method ViewRowImpl.populateAttribute(...) to populate the values without marking the attributes as changed).
    • In the "Update" button's ReturnListener invoke this method instead of re-executing the VO's query.

     

    Dimitar

     

    Message was edited by: DimitarDimitrov P.S. My understanding of the use case described here was wrong. Please, ignore this post.

  • 8. Re: How to refresh the Table of a parent windows after closing child window.
    986494 Newbie
    Currently Being Moderated

    Hi Dimitar ..

     

    The Use Case is same as what you have given in your first post. It is exactly the same thing that I m using in my application.

    The only concern comming is When I try to make any new entry into the DB (calling Stored Procedure Programatically in AMIMPL on click of update button on the child page). it does not refreshed the new entry into the table. I have tried to debug it and i found that the returnListener is not getting called for the first time when it creates a new entry. after that if i try to update that entry the table refreshes.

     

    Please let me know if you require any more information

     

    Thanks

    Zoran Cena

  • 9. Re: How to refresh the Table of a parent windows after closing child window.
    Dimitar Dimitrov Expert
    Currently Being Moderated

    Hi again,

     

    I created a test case and I was able to reproduce the problem. For some reason the table shows the same number of rows after PPR refresh, thus ignoring some rows that exist in the DB (e.g. the new rows in your case). The rows shown may be the same or may be different, but their number remains the same thus ignoring some existing DB rows.

     

    The good news is that there is a workaround . The workaround is to clear the VO cache Instead of re-executing the VO's query in the ReturnListener, i.e. invoke vo.clearCache() instead of vo.executeQuery(). Alternatively, if you are not working directly with the VO but with the DCIteratorBinding, you can invoke iter.getViewObject().clearCache() instead of iter.executeQuery().

     

    In my opinion, the real problem is that VO does not recalculate its Estimated Row Count after vo.executeQuery() and it keeps the previous value. I checked that with the debugger. The UI table displays as many rows as the Estimated Row Count is. When vo.clearCache() is invoked the VO recalculates its Estimated Row Count and the correct number of rows is shown .

     

    Dimitar

  • 10. Re: How to refresh the Table of a parent windows after closing child window.
    Timo Hahn Oracle ACE
    Currently Being Moderated

    @DimitarDimitrov have you tested this with 11.1.1.7.0 or 12c?

    If this behavior can be reproduced in these versions you should open an issue in the adf-emg issue tracker (https://java.net/jira/browse/ADFEMG).

     

    Timo

  • 11. Re: How to refresh the Table of a parent windows after closing child window.
    986494 Newbie
    Currently Being Moderated

    Hi Dimitar

     

    Thanks a lot for working arround.

     

    But my concern is

    Why isn't it (returnListner) is getting called for the first time wen i make a new entry. ?

    Why is it called only when i try to make an update for that entry ?

     

    Thanks

    Zoran Cena

  • 12. Re: How to refresh the Table of a parent windows after closing child window.
    Dimitar Dimitrov Expert
    Currently Being Moderated

    I did not experience such behavior (i.e. ReturnListener not getting called). The ReturnListener in my test case was called properly as expected. The problem that I reproduced with my test case was that the refreshed table in the parent page did not show all the rows from the DB and I workarounded it by invoking vo.clearCache() instead of vo.executeQuery(). By the way, there is another workaround - to configure the VO to fetch all the rows at once (if you can afford that), then vo.executeQuery() refreshes the Estimated Row Count properly.

     

    There must be something specific in your application for the ReturnListener not getting called sometimes. I do not see any relation between creation of some DB rows and the invocation of the ReturnListener.

     

    I am closing the dialog in my test case by a command button that inserts and commits a new DB row and then closes the dialog programmatically:

    public void createDept(ActionEvent actionEvent)
      {
        BindingContext bctx = BindingContext.getCurrent();
        DataControl dc = bctx.findDataControl("AppModuleDataControl");
        AppModule am = (AppModule)dc.getDataProvider();
        am.createDept(deptID); // This custom client method of mine inserts and commits a new row in the DB
        // Close the dialog
        AdfFacesContext.getCurrentInstance().returnFromDialog(null, null);
      }
    


    And here is my ReturnListener in the parent page:

      public void returnFromCreateDept(ReturnEvent returnEvent)
      {
        BindingContext bctx = BindingContext.getCurrent();
        // Refresh the VO
        DataControl dc = bctx.findDataControl("AppModuleDataControl");
        AppModule am = (AppModule)dc.getDataProvider();
        ViewObject vo = am.findViewObject("DepartmentsView");
        vo.clearCache();
        // An alternative way to refresh the VO
    //    DCBindingContainer pagedef = (DCBindingContainer)bctx.getCurrentBindingsEntry();
    //    DCIteratorBinding iter = pagedef.findIteratorBinding("DepartmentsViewIterator");
    //    iter.getViewObject().clearCache();
        // PPR refresh of the UI table
        AdfFacesContext.getCurrentInstance().addPartialTarget(deptTable);
      }
    


    How do you close the dialog in your application? Do you see any exceptions in the stack trace that might have prevented proper invocation of the ReturnListener? When is the ReturnListener not getting called - whenever you create new DB entries or only the first time when you create new DB entries?

     

    Dimitar

  • 13. Re: How to refresh the Table of a parent windows after closing child window.
    Dimitar Dimitrov Expert
    Currently Being Moderated

    Hi Timo,

     

    I have not tested it with 11.1.1.7 and 12.0.2.0 yet. I tested it with 11.1.1.4 (the version of Zoran) and with 11.1.1.6 and both versions reproduced the problem of the table showing an incomplete result set. This problem occurs only when the table is refreshed in a ReturnListener when returning back from a dialog. The table refreshes properly if the refresh is triggered by standard PPR through a command button in the page (either declarative PPR or programmatic PPR) even though the VO's Estimated Row Count is not correct (which is confusing me ), so I will provide some more research before deciding whether to file a bug.

     

    Dimitar

1 2 Previous Next

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points