Oracle ADF web browser refresh button gets old page

北慕城南 提交于 2019-12-11 13:21:11

问题


i'm developing an ADF application. I have a problem. My Jdev version 11.1.2.3.0.

So, For example i have an URL like this "http://www.hohoho.com/view/index.xhtml?_adf.ctrl-state=ju9lnu5ld_3"

In this page i have a table gets value from DB. For example again, i changed some rows in DB browser, and clicked the web browser's refresh button. But new results doesnt get!. For example i remove the "?_adf.ctrl-state=ju9lnu5ld_3" and enter url, this gets new results. How can handle this situation. I need that when an user clicked the refresh button, last result must be fetched. I think it is based on ADF state. How can handle this situation.

Solution

Thanks Andread, mysql's autocommit property default value is true, not false :) but i was using it false. I've solved the problem like yours, but my own solution so cool :) I've only overried the clearCache() method. And it solved the problem.

 public void clearCache() {
        getDBTransaction().commit(); // added
        super.clearCache();
    } 

回答1:


The results from the query are cached in the middle tier. This is the reason why updates to the database which are applied through a different channel than through your application are not reflected when the page reloads.

I am using JDeveloper 11.1.1.7. Setting the "CacheResults" property on the Iterator to false solved this issue (go to the "Bindings" tab of your page or page fragment which contains the table, select the Iterator Executable for your table data, and in the Property Inspector at the "Advanced" section, set "CacheResults" to "false").

In terms of XML, the iterator definition in the PageDef.xml file should look like

<iterator id="TestIterator" Binds="TestView1"
          DataControl="AppModuleDataControl" RangeSize="25"
          CacheResults="false"/>

There seem to be some additional approaches to solve this, probably this was necessary in earlier JDeveloper versions:

  • http://technology.amis.nl/2012/06/18/notifying-adf-applications-of-database-changes-fast-and-lean-using-database-query-result-change-notification-part-one/
  • http://radio-weblogs.com/0118231/stories/2005/06/16/whyIsntRefreshingTheBrowserPageEnoughToRefreshTheDataDisplayed.html

ADDENDUM 03-DEC-2012

OP uses MySQL. With MySQL, setting the CacheResults property is required, but not sufficient. By default, MySQL runs with autocommit=false which has the side effect of using the isolation level REPEATABLE READ. A SELECT implicitly opens a transaction, and subsequent SELECTs return the same result. The Oracle RDBMS uses READ COMMITTED by default, so that data inserted and committed in one session is returned by SELECT in a different session.

One solution to get around this in ADF is to create an implementation class for the View Object, override executeQueryForCollection() and commit the transaction before executing the query:

protected void executeQueryForCollection(Object object, Object[] object2, int i) {
    getApplicationModule().getTransaction().commit();
    super.executeQueryForCollection(object, object2, i);
}

Please use this carefully and review your actual isolation level requirements to make sure that you do not unintentionally commit data by a browser refresh. Another drawback of this solution is that it is not portable between Oracle RDBMS and MySQL.

See https://github.com/afester/StackOverflow/tree/master/AdfRefresh for an SSCCE.



来源:https://stackoverflow.com/questions/13626438/oracle-adf-web-browser-refresh-button-gets-old-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!