我有一个带有滑块和重置按钮的JSF表单:
<div class="field">
<p:outputLabel for="amount" value="Amount" />
<h:panelGrid columns="1" style="margin-bottom: 10px" id="amount">
<p:inputText id="slider" value="#{myBean.myBo.amount}" />
<p:slider for="slider" maxValue="20" />
</h:panelGrid>
</div>
<h:commandButton value="Reset" type="reset" action="#{myBean.reset}" update="form" process="@this" class="button"></h:commandButton>
重置功能如下所示:
public void reset() {
RequestContext.getCurrentInstance().reset("form:form");
this.registrationFormBo.clear();
}
p:inputText
具有正确的值,而滑块本身在此示例中的值为9。
问题
值为滑块时不会重置。
答案 0 :(得分:0)
<强>解强>
我使用Primefaces p:resetInput
解决了这个问题。重置按钮的最终html如下所示:
<p:commandButton value="Reset" update="registrationForm" process="@this" >
<p:resetInput target="registrationForm" />
</p:commandButton>
这会正确地重置滑块和表单中的所有其他元素。