单击按钮时如何在 JDeveloper 中隐藏 AFD 组件?

问题描述

我尝试了以下方法来隐藏 ADF 组件,但它不起作用,知道我做错了什么吗?

#{不是 mainBean.RequestBean.applyButton.selected}

我希望这行代码在单击 applyButton 时隐藏一个表格,但它什么也没做。

解决方法

您需要在单击按钮时刷新组件才能使条件为真。在按钮事件末尾添加:

UIComponent component = findComponentInRoot("YOUR_COMPONEND_ID");
AdfFacesContext.getCurrentInstance().addPartialTarget(component.getParent()); //This will ask adf to trigger an ajax refresh on your component

在你的 java bean 中查找组件:

    /**
 * Locate an UIComponent in view root with its component id. Use a recursive way to achieve this.
 * @param id UIComponent id
 * @return UIComponent object
 */
public static UIComponent findComponentInRoot(String id) {
    UIComponent component = null;
    if (id != null) {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        if (facesContext != null) {
            UIComponent root = facesContext.getViewRoot();
            if (root != null) {
                component = findComponent(root,id);
            }
        }
    }
    return component;
}

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...