问题
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