Primefaces滑块不会重置为0

时间:2016-09-26 11:05:13

标签: primefaces jsf-2 slider

我有一个带有滑块和重置按钮的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();
}

重置滑块时,其输出如下所示: enter image description here

p:inputText具有正确的值,而滑块本身在此示例中的值为9。

问题

值为滑块时不会重置。

1 个答案:

答案 0 :(得分:0)

<强>解

我使用Primefaces p:resetInput解决了这个问题。重置按钮的最终html如下所示:

<p:commandButton value="Reset" update="registrationForm" process="@this" >
    <p:resetInput target="registrationForm" />
</p:commandButton>

这会正确地重置滑块和表单中的所有其他元素。