双击table中的某行,然后跳转到该行的查看视图。
分别在页面 Table组件中加入 客户端监听和服务监听,加入JS代码,调用BackingBean,执行跳转。
ADF Table 中需要的属性:
页面中Table组件,加粗部分为需要添加的代码。
<af:table value="#{bindings.UserTableView1.collectionModel}"
var="row"
rows="#{bindings.UserTableView1.rangeSize}"
filterVisible="true" varStatus="vs"
selectedRowKeys="#{bindings.UserTableView1.collectionModel.selectedRow}"
selectionListener="#{bindings.UserTableView1.collectionModel.makeCurrent}"
rowSelection="single" id="t1"
partialTriggers="::cb3"
binding="#{backingBeanScope.staffManageBean.t1}"
styleClass="AFStretchWidth" >
<af:clientListener method="handleTableDoubleClick" type="dblClick"/>
<af:serverListener type="TableDoubleClickEvent" method="#{backingBeanScope.staffManageBean.handleTableDoubleClick}"/>
<af:column sortProperty="#{bindings.UserTableView1.hints.StaffNo.name}"
filterable="true" sortable="false"
headerText="#{bindings.UserTableView1.hints.StaffNo.label}"
id="c5">
<af:outputText value="#{row.StaffNo}" id="ot5"/>
</af:column>
....
form组件中加如下JS:
<af:resource type="javascript" >
function handleTableDoubleClick(evt){
var table = evt.getSource();
AdfCustomEvent.queue(table, "TableDoubleClickEvent",{}, true);
evt.cancel();
}
</af:resource>
backingBean中的代码:
public void handleTableDoubleClick(ClientEvent ce){ navToOutCome("toView");//跳转到taskFlow中的 “toView”页面 //刷新Psl1为页面第一个组件,上级为改页面Jsff,即刷新Jsff AdfFacesContext.getCurrentInstance().addPartialTarget(this.getPsl1().getParent()); } //跳转方法 public void navToOutCome(String outCome) { FacesContext facesContext = FacesContext.getCurrentInstance(); Application application = facesContext.getApplication(); NavigationHandler navigationHandler = application.getNavigationHandler(); ControllerContext controllerContext = ControllerContext.getInstance(); String viewId = controllerContext.getCurrentViewPort().getViewId(); if (viewId != null) { navigationHandler.handleNavigation(facesContext, viewId, outCome); } }