f:setPropertyActionListener未设置值,但是触发了操作 [英] f:setPropertyActionListener doesn't set the value however action is triggered

查看:47
本文介绍了f:setPropertyActionListener未设置值,但是触发了操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无论何时切换p:fieldset,我都需要设置一个布尔字段.我尝试了以下代码,但是尽管p:ajax侦听器在切换时被调用,但f:setPropertyActionListener从未设置该字段.我尝试了以下代码.

I need to set a boolean field whenever p:fieldset is toggled. I tried out following code but the field is never set by f:setPropertyActionListener although p:ajax listener is invoked on toggle. I tried out following code.

    <p:fieldset legend="(Optional) Link.." toggleable="true">
        <p:ajax event="toggle" listener="..">
            <f:setPropertyActionListener target="#{viewScope.rendrUsrProjctsList}" value="#{true}"/>
        </p:ajax>
    </p:fieldset>

但是,当我尝试如下修改代码时,则成功设置了字段:

However when I tried modifying the code as below then field is successfully set:

    <p:fieldset legend="(Optional) Link.." toggleable="true">
        <p:ajax event="toggle" listener="#{view.viewMap.put('rendrUsrProjctsList', true)}" />
        <p:ajax event="toggle" listener=".."/>
        </p:ajax>
    </p:fieldset>

我想问:

  1. 为什么第一种方法不起作用?
  2. 是否将多个p:ajax附加到 单亲父母是否以第二种方式完成了?
  1. Why 1st way doesn't work ?
  2. Is it bad attaching multiple p:ajax to single parent as done in 2nd way ?

推荐答案

ActionListener 实现仅在实现 ActionSource 接口,例如 UICommand ,即<h:commandXxx><p:commandXxx>等.<p:ajax>没有实现此接口,因此<f:setPropertyActionListener>基本上被完全忽略.

The <f:setPropertyActionListener> works as being an ActionListener implementation only on components implementing ActionSource interface, such as UICommand, i.e. <h:commandXxx>, <p:commandXxx>, etc. The <p:ajax> does not implement this interface and therefore the <f:setPropertyActionListener> is basically completely ignored.

关于您的解决方法,您可以这样做,尽管我宁愿只使用具体的视图作用域bean或将其包装在具有支持组件的复合材料中.

As to your workaround, you could do so although I'd rather just use a concrete view scoped bean or wrap it in a composite with a backing component.

这篇关于f:setPropertyActionListener未设置值,但是触发了操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆