2
我想爲我的h:selectOneMenu設置一個默認值,但由於某種原因,第一個項目(見下文)不是第一個選擇的項目。第三項是「默認選擇」項目。默認爲h:selectOneMenu與jsf
<h:selectOneMenu value="#{bookBean.discountPercentage}">
<f:selectItem itemLabel="Please select a value: " noSelectionOption="true" />
<f:selectItems value="#{bookBean.paymentMethods}" var="paymentMethod"
itemValue="#{paymentMethod.discountPercentage}"
itemLabel="#{paymentMethod}" required="true"/>
<f:ajax listener="#{bookBean.setDiscountValue}"/>
</h:selectOneMenu>
所以「請選擇一個值」必須在列表中(這是)的第一個項目,它具有開放TE頁面時要選擇的值,而事實並非如此。
你使用什麼jsf版本? bookBean還有什麼範圍?你有沒有調試過bookBean.discountPercentage? getter會在頁面刷新時返回什麼? – spauny