confirmDialog is not taken the new value of the selectOneMenu

1000 views Asked by At

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?

2

There are 2 answers

0
Mathieu Castets On BEST ANSWER

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>
0
Miguel On

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.