f:setPropertyActionListener doesn't set the value however action is triggered

一个人想着一个人 提交于 2019-12-31 01:33:07

问题


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>

I want to ask:

  1. Why 1st way doesn't work ?
  2. Is it bad attaching multiple p:ajax to single parent as done in 2nd way ?

回答1:


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.

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.



来源:https://stackoverflow.com/questions/15876257/fsetpropertyactionlistener-doesnt-set-the-value-however-action-is-triggered

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!