3
如何在重置類型時按下p:commandButton來重置p:selectOneMenu的值。代碼中,我有如下如何重置primefaces上的下拉命令按鈕重置類型
<h:form id="form">
<p:panelGrid columns="2" cellspacing="10" >
<f:facet name="header">Login</f:facet>
<p:outputLabel value="Username" />
<p:inputText value="#{user.username}" />
<p:outputLabel value="Password" />
<p:password value="#{user.password}"></p:password>
<p:outputLabel value="Locale" />
<p:selectOneMenu >
<f:selectItem itemValue="Select Country" itemLabel="Select Country" />
<f:selectItem itemValue="Poland" itemLabel="Poland"/>
</p:selectOneMenu>
<p:commandButton value="Submit"></p:commandButton>
<p:commandButton type="reset" value="Clear" update="form"></p:commandButton>
</p:panelGrid>
</h:form>
在這樣做時,用戶名和密碼被清除,但對於選擇國家下拉不復位。