jsf - 从阶段侦听器(beforePhase 或 afterPhase)访问 adf 中页面片段的 UI 组件
问题描述
我是 Oracle ADF 的新手,当 JSPX 的阶段侦听器运行时,我需要帮助才能访问 JSPX 文件上的页面片段的 UI 组件。
我有这个 .jspx 文件,其中包含一个af:region。该区域连接到页面片段(.jsff)文件,我想从 JSPX 文件的页面阶段侦听器(beforePhase 或 afterPhase 事件)访问页面片段内部的 UI 组件(例如 inputText 等) .
页面片段绑定到 pageFlowScope bean 及其所有 UI 组件。但是当我尝试从阶段侦听器事件中访问 bean 时,绑定到 bean 的 UI 组件尚未初始化并返回 NullPointerException。
我现在正在考虑尝试通过阶段侦听器事件的“id”访问 UI 组件。这可能吗?
解决方案
您可以直接从视图页面 El Expression 检索绑定的 inputText 或阶段侦听器中的任何其他 ADF 组件的值。这是一个简单的例子:https ://cedricleruth.com/how-to-retreive-the-value-of-an-iterator-binding-variable-programmatically-in-adf/
在你的情况下,它看起来像:
//Below is a view example with values taken from an ADF View Object. Don't forget to add an MVCE next time
//<af:inputText id="it1" autoSubmit="true" value="#{bindings.YOUR_VO.YOUR_VO_ATTRIBUTE.inputValue}" />
public static void YOUR_PHASE_EVENT(PhaseEvent pe) {
String inputTextValue= (String)this.resolveExpression("#{bindings.YOUR_VO.YOUR_VO_ATTRIBUTE.inputValue}");
//Do whatever you want with it
}
/**
* Method for taking a reference to a JSF binding expression and returning
* the matching object (or creating it).
* @param expression EL expression
* @return Managed object
* @author : Duncan Mills, Steve Muench and Ric Smith's JSFUtils class
*/
public static Object resolveExpression(String expression) {
FacesContext facesContext = getFacesContext();
Application app = facesContext.getApplication();
ExpressionFactory elFactory = app.getExpressionFactory();
ELContext elContext = facesContext.getELContext();
ValueExpression valueExp = elFactory.createValueExpression(elContext, expression, Object.class);
return valueExp.getValue(elContext);
}
推荐阅读
- mongodb - 如何将 spark 数据集转换为 geomesa 特征?
- jenkins-pipeline - 如何使用 Jenkins CLI 触发并进入管道的下一阶段?
- python - 使用 REST API 异步更新网站
- python-3.x - 一个tkinter代码片段的分析和理解
- python - yolov3中CNN的真实层数是多少?
- python - 如何使用“ggplot”处理大型 Pandas 数据框以可视化 R 中的数据?
- javascript - 拆分前两个空格的字符串
- python - 出现语法错误:扫描三引号字符串文字时出现 EOF
- java - jHipster 应用程序升级到 5.8.2 后无法运行
- css - 减少边距并下推下面的内容