首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >adf selectOneChoice valueChangeListener不开火

adf selectOneChoice valueChangeListener不开火
EN

Stack Overflow用户
提问于 2015-02-13 23:23:18
回答 2查看 12.7K关注 0票数 0

当我试图在下拉列表中选择一个值时,不会调用我的valueChangeListener for SelectOneChoice。只有当我单击下拉列表(我们在ListOfValues中配置的)中的空白项时,才会调用它。在一些研究中,我了解到在你们的valueChangeListener中,我们必须增加

vce.getComponent().processUpdates(FacesContext.getCurrentInstance());

作为我们的第一条线。但是,在选择除null以外的任何其他值时,仍然不会调用它。

我的 SelectOneChoice代码

代码语言:javascript
复制
<af:selectOneChoice value="#{bindings.Prefix.inputValue}"
                    label="#{bindings.Prefix.label}"
                    shortDesc="#{bindings.Prefix.hints.tooltip}"
                    id="soc3"
                    partialTriggers="formatIdId"
                    visible="#{bindings.Prefix.hints.visible}"
                    binding="#{backingBeanScope.CreateItemBackingBean.prefixField}"
                    required="#{bindings.ItemNumberType.attributeValue eq 'VPLU'}"
                    showRequired="#{bindings.Prefix.hints.mandatory}"
                      validator="#{backingBeanScope.CreateItemBackingBean.onValidatePrefix}"
                      autoSubmit="true"
                     valueChangeListener="#{backingBeanScope.CreateItemBackingBean.onChangePrefix}">
    <f:selectItems value="#{bindings.Prefix.items}" id="si3"/>
    <af:convertNumber groupingUsed="false"
                        pattern="#{bindings.Prefix.format}"/>
</af:selectOneChoice>   

我的 ValueChangeListener代码

代码语言:javascript
复制
    public void onChangePrefix(ValueChangeEvent vce) {
         vce.getComponent().processUpdates(FacesContext.getCurrentInstance());
         System.out.println("vce.getOldValue()"+vce.getOldValue());
        System.out.println("vce.getNewValue()"+vce.getNewValue());
        System.out.println("I am in changed prefix");
}
EN

回答 2

Stack Overflow用户

发布于 2015-02-14 13:16:39

只有当您提交表单时,valueChangeListener才会触发。您可以对其使用任何提交操作,也可以只在组件上打开autosubmit属性。

如果您需要捕获选择事件而不实际提交数据,则应该使用clientListener并使用javascript函数处理它。

票数 2
EN

Stack Overflow用户

发布于 2015-02-17 07:43:12

这可能是您需要的标记,防止valueChangeListener触发。

代码语言:javascript
复制
required="#{bindings.ItemNumberType.attributeValue eq 'VPLU'}"

如果“必需”返回true,则不会执行valueChangeListener。另外,完全删除"showRequired“属性。不仅没有必要,而且令人困惑,因为它具有与“必需”属性不同的条件。

尝试一些调试,并设置required="false".You也可以删除“验证器”、“可见的”,看看没有它们是否有效,然后一个一个地将它们添加回来。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28510418

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档