夥計。 我被困在以下問題上。我有一個模式對話框,其中包含兩個selectOneMenu組件。當我關閉對話框並再次打開時,selectoneMenu中的值仍然被選中。這是我的菜單:Primefaces:selectOneMenu not reset
<p:selectOneMenu id="fromCurrency"
value="#{dialog.exchangeRateManageContainer.currencyIdFrom}"
styleClass="ui-input-required"
required="true"
requiredMessage="#{msgs['validation.maintenance.exchangeRate.fromCurrency']}">
<f:selectItem
itemLabel="#{msgs['label.maintenance.selectCurrency']}"/>
<f:selectItems value="#{dialog.currencies}" var="currency"
itemLabel="#{currency.code}"
itemValue="#{currency.currencyId}"/>
</p:selectOneMenu>
<p:outputLabel for="toCurrency" value="#{msgs['label.maintenance.toCurrency']}" />
<p:selectOneMenu id="toCurrency"
value="#{dialog.exchangeRateManageContainer.currencyIdTo}"
styleClass="ui-input-required"
required="true"
requiredMessage="#{msgs['validation.maintenance.exchangeRate.toCurrency']}">
<f:selectItem itemLabel="#{msgs['label.maintenance.selectCurrency']}"/>
<f:selectItems value="#{dialog.currencies}" var="currency"
itemLabel="#{currency.code}"
itemValue="#{currency.currencyId}"/>
這是取消鍵:
<p:commandButton id="cancelButton"
value="#{msgs['label.button.cancel']}"
icon="ui-icon-cancel"
action="#{dialog.cancel()}"
immediate="true"
process="@this"
oncomplete="addExchangeRateDialog.hide();"/>
這是取消方法:
public void cancel() {
manageCurrenciesDialog = null;
}
任何幫助將不勝感激。
您是否閱讀過此鏈接:http://stackoverflow.com/questions/20169208/how-to-reset-input-components-on-change-of-pselectonemenu-after-certain-valid? – JGeo
此外,此鏈接可能有助於http://stackoverflow.com/questions/16251156/how-to-reset-dropdown-on-primefaces-commandbutton-reset-type –
這可能有很多原因。也許你沒有清除bean中的值,或者在打開它之前不刷新/更新對話框,或者在驗證失敗並且對話框狀態未清除後關閉對話框。您發佈的代碼不足以說明問題。 –