ADF (Application Development Framework) 11g R1是Oracle提供的一个企业级Java EE开发框架,用于构建富互联网应用程序。在ADF中,弹出窗口通常通过af:dialog
或af:popup
组件实现,而表格则通常使用af:table
组件。
首先,确保你的页面中有以下组件:
af:table
)af:popup
或af:dialog
)要实现这个功能,你需要使用ADF的Partial Page Rendering (PPR)机制和JavaScript API。以下是具体实现步骤:
<!-- 弹出窗口中的确定按钮 -->
<af:commandButton text="确定" id="cb1">
<!-- 刷新表格 -->
<af:returnActionListener/>
<!-- 关闭弹出窗口 -->
<af:clientAttribute name="returnPopupId" value="popup1"/>
</af:commandButton>
<!-- 弹出窗口中的确定按钮 -->
<af:commandButton text="确定" id="cb1">
<af:clientListener method="closePopupAndRefreshTable" type="action"/>
<af:serverListener type="refreshTableEvent" method="#{yourBean.refreshTableMethod}"/>
</af:commandButton>
<!-- 表格组件 -->
<af:table id="table1" value="#{yourBean.tableData}" ...>
<af:clientListener method="refreshTable" type="refreshTableEvent"/>
</af:table>
<!-- JavaScript代码 -->
<af:resource type="javascript">
function closePopupAndRefreshTable(evt) {
var popup = AdfPage.PAGE.findComponentByAbsoluteId('popup1');
var table = AdfPage.PAGE.findComponentByAbsoluteId('table1');
// 关闭弹出窗口
AdfPage.PAGE.hidePopup(popup);
// 刷新表格
AdfUIComponent.queueEvent(table, new AdfCustomEvent(table, "refreshTableEvent", {}, true));
}
</af:resource>
<!-- 弹出窗口中的确定按钮 -->
<af:commandButton text="确定" id="cb1">
<af:actionListener type="#{yourBean.yourActionListener}"/>
<af:clientAttribute name="returnPopupId" value="popup1"/>
</af:commandButton>
<!-- 在后台Bean中 -->
public void yourActionListener(ActionEvent actionEvent) {
// 刷新表格数据
refreshTableData();
// 添加JavaScript代码来关闭弹出窗口
FacesContext context = FacesContext.getCurrentInstance();
ExtendedRenderKitService erks =
Service.getRenderKitService(context, ExtendedRenderKitService.class);
erks.addScript(context, "AdfPage.PAGE.hidePopup('popup1');");
}
原因:可能没有正确触发PPR或后台数据没有更新 解决方案:
partialTriggers
属性设置为触发按钮的ID原因:JavaScript执行错误或组件ID不正确 解决方案:
AdfPage.PAGE.findComponentByAbsoluteId
确保获取正确的组件原因:可能因为页面刷新导致弹出窗口状态重置 解决方案:
af:returnActionListener
)而不是自定义JavaScriptaf:serverListener
和af:clientListener
组合这种技术常用于以下场景:
以上方法在ADF 11g R1中经过验证,可以根据具体需求选择最适合的实现方式。
没有搜到相关的文章