Oracle ADF Web浏览器刷新按钮显示旧页面 [英] Oracle ADF web browser refresh button gets old page

查看:81
本文介绍了Oracle ADF Web浏览器刷新按钮显示旧页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发ADF应用程序.我有个问题.我的Jdev版本11.1.2.3.0.

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

因此,例如,我有一个类似"http://www.hohoho.com/view/index.xhtml?_adf.ctrl-state=ju9lnu5ld_3"的URL

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

在此页面中,我有一个表格,可以从DB中获取价值.再次举例来说,我在数据库浏览器中更改了一些行,然后单击Web浏览器的刷新按钮.但是没有得到新的结果!例如,我删除?_adf.ctrl-state = ju9lnu5ld_3"并输入网址,这将获得新的结果.如何处理这种情况.我需要当用户单击刷新按钮时,必须获取最后的结果.我认为它基于ADF状态.如何处理这种情况.

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.

解决方案

感谢Andread,mysql的autocommit属性默认值为true,不是false :),但我使用的是false.我已经解决了像您一样的问题,但是我自己的解决方案太酷了:)我只覆盖了clearCache()方法.它解决了问题.

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();
    } 

推荐答案

查询结果缓存在中间层.这就是为什么在页面重新加载时不反映通过与应用程序不同的渠道应用的数据库更新的原因.

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.

我正在使用JDeveloper 11.1.1.7.将 Iterator 上的"CacheResults"属性设置为false,可以解决此问题(转到包含表的页面或页面片段的"Bindings"选项卡,为表数据选择Iterator Executable ,然后在属性"检查器的高级"部分,将"CacheResults"设置为"false").

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").

就XML而言,PageDef.xml文件中的迭代器定义应类似于

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"/>

似乎有一些其他方法可以解决此问题,这可能在早期的JDeveloper版本中是必需的:

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

附录2012年12月3日

OP使用MySQL.对于MySQL,设置CacheResults属性是必需的,但还不够.默认情况下,MySQL使用autocommit=false运行,该autocommit=false具有REPEATABLE READ的副作用. SELECT隐式地打开一个事务,随后的SELECTs返回相同的结果. Oracle RDBMS默认情况下使用READ COMMITTED,以便在一个会话中插入和提交的数据由SELECT在另一个会话中返回.

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.

在ADF中解决此问题的一种解决方案是为视图对象创建一个实现类,重写executeQueryForCollection()并在执行查询之前提交事务:

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);
}

请仔细使用它,并查看您的实际隔离级别要求,以确保您不会在刷新浏览器时无意间提交数据.该解决方案的另一个缺点是它不能在Oracle RDBMS和MySQL之间移植.

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.

请参见 https://github.com/afester/StackOverflow/tree/master/AdfRefresh 用于SSCCE.

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

这篇关于Oracle ADF Web浏览器刷新按钮显示旧页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆