confirmDialog is not taken the new value of the selectOneMenu

自作多情 提交于 2019-12-13 04:55:22

问题


I need to change the status in database but when I change the status the confirmDialog is not taking the new value, it gets the old one

<p:selectOneMenu converter="omnifaces.SelectItemsConverter" disabled="#{myBB.currentStatus != StatusEnum.TEMP}"
    id="statusSOM" onchange="PF('confirm').show();" value="#{myBB.currentStatus}" widgetVar="statusWV">
    <f:selectItems itemDisabled="#{status == StatusEnum.ALL}" itemLabel="#{msgs[status.name]}"
        itemValue="#{status}" value="#{myBB.statusList}" var="status" />
</p:selectOneMenu>

<p:confirmDialog widgetVar="confirm" message="Save?" header="Confirm" severity="alert">
    <p:commandButton action="#{myBB.saveStatus}" oncomplete="PF('confirm').hide();"
        update="form1 form2" value="Yes" />
    <p:commandButton value="No" type="button"
        onclick="PF('statusWV').selectValue(PF('statusWV').preShowValue.val());PF('confirm').hide();" />
</p:confirmDialog>

What can I do?


回答1:


You need to update your p:confirmDialog component when the value is updated. That's straightfoward if you use the handy p:ajax on your p:selectOneMenu.

<p:selectOneMenu converter="omnifaces.SelectItemsConverter" disabled="#{myBB.currentStatus != StatusEnum.TEMP}" id="statusSOM" value="#{myBB.currentStatus}" widgetVar="statusWV">
     <f:selectItems itemDisabled="#{status == StatusEnum.ALL}" itemLabel="#{msgs[status.name]}" itemValue="#{status}" value="#{myBB.statusList}" var="status" />
     <p:ajax event="change" update="confirmdialog" oncomplete="PF('confirm').show()" />
</p:selectOneMenu>

<p:confirmDialog id="confirmdialog" widgetVar="confirm" message="Save?" header="Confirm" severity="alert">
    ...
</p:confirmDialog>



回答2:


My reputation is not enough for posting a comment, sorry. Have you surrounded your JSF code with the same <h:form> tag?

I remember you that in your method saveStatus you must to get the value from currentStatus.

Please, post your ManagedBean code.



来源:https://stackoverflow.com/questions/30878397/confirmdialog-is-not-taken-the-new-value-of-the-selectonemenu

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