选中复选框后启用ADF输入文本

时间:2017-09-19 10:21:04

标签: oracle-adf

我是ADF的新手,我希望在选中复选框后显示/启用输入文本框,我在下面取消选中时应该禁用复选框ADF代码,

ADF代码:

<af:selectBooleanCheckbox label="Apply WITSML Filter" id="sbc11"
autoSubmit="true" contentStyle="margin-left:10px;" valueChangeListener="#{pageFlowScope.welljobs_bean.applyWITSMLFilterIndicator}"/>

豆:

private transient RichSelectBooleanCheckbox applyWITSMLFilterIndicator;
    public void setapplyWITSMLFilterIndicator(RichSelectBooleanCheckbox applyWITSMLFilterIndicator) {
        this.applyWITSMLFilterIndicator= applyWITSMLFilterIndicator;
    }

    public RichSelectBooleanCheckbox getapplyWITSMLFilterIndicator() {
        return applyWITSMLFilterIndicator;
    }

我要显示的输入文字:

 <af:inputText id="it140" autoComplete="off"
 binding="#{pageFlowScope.welljobs_bean.applyWITSMLFilterIndicator.curvesFilter}"
 dimensionsFrom="content" editable="inherit" rendered="true"/>

豆:

 private transient RichInputText curvesFilter;
        public void setCurvesFilter(RichInputText curvesFilter) {
            this.curvesFilter = curvesFilter;
        }
        public RichInputText getCurvesFilter() {
            return curvesFilter;
        }

有人可以帮忙吗? 它也给了我javax.faces.FacesException:javax.el.PropertyNotFoundException:类&#39; java.lang.String&#39;没有属性&#39; curvesFilter&#39;。例外

1 个答案:

答案 0 :(得分:0)

您可以使用EL Expression,部分触发/自动提交和ValueChangeEvent执行此操作。

您希望在bean中保存checkedbox的布尔值,以便在valueChangeEventListener中更改此值时可以呈现或禁用inputText。

然后,您需要刷新inputText,以便通过将以下属性添加到inputText父级来显示它的新渲染/禁用值:

partialTriggers="sbc11"

partialTriggers会在您给予他的元素ID上发生操作时刷新容器的全部内容。

假设您要禁用/启用inputText:

Bean:

public boolean checkboxIsChecked = false; //or private with getter and setter
public void checkBoxValueChange(ValueChangeEvent ve){
    this.checkboxIsChecked = ve.getNewValue();
}

Jsf:

<af:selectBooleanCheckbox label="Apply WITSML Filter" id="sbc11"
autoSubmit="true" contentStyle="margin-left:10px;" valueChangeListener="#
{pageFlowScope.welljobs_bean.checkBoxValueChange}"/>

...

 <af:inputText id="it140" autoComplete="off"
 binding="#{pageFlowScope.welljobs_bean.applyWITSMLFilterIndicator.curvesFilter}"
 dimensionsFrom="content" disabled="#{pageFlowScope.welljobs_bean.checkboxIsChecked}"/>
不要忘记添加partialTriggers =&#34; CHECKBOXID&#34;到inputText父容器

有关官方示例,请参阅文档:https://docs.oracle.com/cd/E16764_01/web.1111/b31973/af_lifecycle.htm#CIAHCFJF