Primefaces update component after <p:ajax listener> [duplicate]

折月煮酒 提交于 2019-12-13 01:37:13

问题


I have a selectOneMenu that changes a value in the backing bean and based on that value, another component is being displayed or not. What I would like is to update that certain component after the value in the backing bean is changed by the selectOneMenu

<h:selectOneMenu value="#{backingBean.id.value}" >
            <f:selectItem itemLabel="Choose" itemValue="0"/>
            <f:selectItems value="#{backingBean.idList}"
                var="id" itemLabel="#{id.name}" itemValue="#{id.value}" />
             <p:ajax listener="#{backingBean.changeId}" process="@this" update="userMenu"/>
</h:selectOneMenu>
<p:menu id="userMenu" rendered="#{backingBean.id.value != 0}">
</p:menu>

The value changes in the backing bean but the is not updated.


回答1:


This should work

<h:selectOneMenu value="#{backingBean.id.value}" >
        <f:selectItem itemLabel="Choose" itemValue="0"/>
        <f:selectItems value="#{backingBean.idList}"
            var="id" itemLabel="#{id.name}" itemValue="#{id.value}" />
         <p:ajax listener="#{backingBean.changeId}" process="@this" update="userMenuWrapper"/>
</h:selectOneMenu>
<p:outputPanel id="userMenuWrapper">
    <p:menu id="userMenu" rendered="#{backingBean.id.value != 0}"/>
</p:outputPanel>


来源:https://stackoverflow.com/questions/32483173/primefaces-update-component-after-pajax-listener

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