【发布时间】:2021-05-30 18:04:41
【问题描述】:
我最近开始使用 JDeveloper 12c 处理我的第一个 ADF 项目。
所以,我有一个连接到 Oracle 数据库的 Fusion Web 应用程序。在其中一个 jsf 页面上有两个 ADF 表,它们显示来自数据库的数据。下面是一个向数据库发送“DELETE”语句以删除选定条目的按钮。由于原因,两个表必须在此之后刷新(删除会影响两个表的显示条目)。
在我已经很高兴表格显示正确的数据并且按钮也完成了它之后,我很快意识到如果数据库发生更改,jsf 页面中的表格将不会自动刷新。我在网上搜索了一些关于如何在 ADF Fusion 应用程序中刷新 jsf 页面元素的入门级教程。遗憾的是,到目前为止,我还没有找到任何可以给我打开它的钥匙的东西。
我在Oracle HQ页面找到this article,但是它也有使用很多专有命名的习惯,并且是用流畅的文本编写的,所以里面没有代码示例或sn-p或类似的东西,所以它新手很难跟上。
这是来自我的托管 java bean 的 sn-p,我在其中存储按钮功能:
public String update() {
getDBConnection c = new DBConnection();
Connection conn = c.getConn();
RowKeySet selectedEntries = getDetailTable().getSelectedRowKeys();
Iterator selectedEntryIter = selectedEntries.iterator();
DCBindingContainer bindings = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
DCIteratorBinding entryIter = bindings.findIteratorBinding("my_iterator");
RowSetIterator rSIter = entryIter.getRowSetIterator();
try {
PreparedStatement pstmt1 = conn.prepareStatement("DELETE ...");
PreparedStatement pstmt2 = conn.prepareStatement("DELETE ...");
while(selectedEntryIter.hasNext()){
Key key = (Key)((List)selectedEntryIter.next()).get(0);
Row currentRow = rSIter.getRow(key);
BigDecimal barcode = (BigDecimal) currentRow.getAttribute("id");
BigDecimal field1 = (BigDecimal) currentRow.getAttribute("field1");
BigDecimal field2 = (BigDecimal) currentRow.getAttribute("field2");
pstmt1.setBigDecimal(1, id);
pstmt1.setBigDecimal(2, field1);
pstmt2.setBigDecimal(1, id);
pstmt2.setBigDecimal(2, field2);
pstmt1.executeUpdate();
pstmt2.executeUpdate();
}
conn.commit();
//i guess here i have to trigger to refresh the tables but I have pretty to no clue of how to do that
//where do I have to set the functionality? I read sth about creating another bean in the "session" package
//but somehow i have to access the jsf i want to have refreshed. Where do I create that connection?
//even a simple example or a good reference to a tutorial would be helpful for me
} catch (SQLException e) {
System.out.println(e.getMessage());
}
return null;
}
可能这个问题与一个已经存在的问题重复,我太愚蠢了,找不到它,但无论如何我都会试一试。提前致谢!
【问题讨论】:
标签: java sql oracle oracle-adf jdeveloper