使用Input Text with LOV组件时,返回值会自动绑定并显示在InputText中。
如果需要通过程序获取返回值,可以定制returnPopupListener。
重要步骤说明:
1. inputListOfValues组件代码如下:
<af:inputListOfValues id="jobIdId" popupTitle="Search and Select: #{bindings.JobId.hints.label}"
value="#{bindings.JobId.inputValue}" label="#{bindings.JobId.hints.label}"
model="#{bindings.JobId.listOfValuesModel}"
required="#{bindings.JobId.hints.mandatory}"
columns="#{bindings.JobId.hints.displayWidth}"
shortDesc="#{bindings.JobId.hints.tooltip}" autoSubmit="true"
returnPopupListener="#{myBackingBean.jobIdReturnPopupListener}">
<f:validator binding="#{bindings.JobId.validator}"/>
<af:autoSuggestBehavior suggestedItems="#{bindings.JobId.suggestedItems}"/>
</af:inputListOfValues>
2. Managed Bean的代码
public void jobIdReturnPopupListener(ReturnPopupEvent returnPopupEvent) {
RowKeySet rowKeySet = (RowKeySet)returnPopupEvent.getReturnValue();
Iterator rksIterator = rowKeySet.iterator();
while (rksIterator.hasNext()) {
List key = (List)rksIterator.next();
RichInputListOfValues lovComp = (RichInputListOfValues)returnPopupEvent.getSource();
ListOfValuesModel lovModel = lovComp.getModel();
CollectionModel collectionModel = lovModel.getTableModel().getCollectionModel();
collectionModel.setRowKey(key);
JUCtrlHierBinding treeBinding = (JUCtrlHierBinding)collectionModel.getWrappedData();
JUCtrlHierNodeBinding nodeBinding = treeBinding.findNodeByKeyPath(key);
String[] strs = nodeBinding.getAttributeNames();
for (String str : strs) {
System.out.println("########################### " + str + ":" + nodeBinding.getAttribute(str));
}
}
}
说明:这里可以获取到LOV的所有字段的值。
3. 运行
输出如下:
########################### JobId:eee
########################### JobTitle:EEE
########################### MaxSalary:2
########################### MinSalary:1
Project 下载:ADF_LOV_InputText(3).7z
没有评论:
发表评论