我有一个弹出窗口显示包含数据的表格,我可以选择一行,按OK按钮我可以检索表格中所选行的idNo。
我想要做的是将此idNo传递给调用弹出窗口的窗口并更新此窗口中的outputText。
有人可以帮助我吗?
按钮代码:
按钮的newBean类:
public String b1_action() {
// Add event code here...
System.out.println("Select One Button has been Clicked");
// Get bindings associated with the current scope, then access the one that we have assigned to our table - e.g. OpenSupportItemsIterator
DCBindingContainer bindings =
(DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
DCIteratorBinding dcItteratorBindings =
bindings.findIteratorBinding("NameView1_1Iterator");
// Get an object representing the table and what may be selected within it
ViewObject voTableData = dcItteratorBindings.getViewObject();
// Get selected row
Row rowSelected = voTableData.getCurrentRow();
// Display attriebute of row in console output - would generally be bound to a UI component like a Label and or used to call another proces
System.out.println(rowSelected.getAttribute("IdNo"));
setOutputText("" + rowSelected.getAttribute("IdNo") + "");
closePopup("p1");
return null;
}
我希望我的功能:setOutputText()
尚未实现,无法在主窗口上更新我的outputText。
由于 最诚挚的问候
答案 0 :(得分:1)
将“IdNo”置于视图或页面流量范围内,具体取决于您希望如何保留值。
//view scope
AdfFacesContext.getCurrentInstance().getViewScope().put("IdNo", value);
//or page flow scope
AdfFacesContext.getCurrentInstance().getPageFlowScope.put("IdNo", value);
在window bean中,为弹出对话框编写一个监听器:
public void dialogCloseListener(DialogEvent dialogEvent) {
if (dialogEvent.getOutcome().equals(DialogEvent.Outcome.ok)) {
String idNo = AdfFacesContext.getCurrentInstance().getViewScope().get("IdNo");
//now you have the idNo, do whatever you want
}
}
答案 1 :(得分:1)
你也可以在按钮或链接中使用returnListener来调用弹出窗口,如this article