In my JSF2 application, I have "Clear" button, which is supposed to clear all the fields. However, it doesn t always work.
My page fragment:
<h:form id="bi">
<h:inputText value="#{bean.entity.firstname}" />
<h:inputText value="#{bean.entity.surname}" />
<h:commandButton value="Clear" immediate="true" action="#{bean.clear}">
<f:ajax render="bi" />
</h:commandButton>
<h:commandButton value="Submit" action="#{bean.submit}" />
</h:form>
和clear(
methods in my bean:
public void clear() {
entity = new Entity();
}
If I enter values in the fields, and click "Clear", everything is cleared as expected. However, consider such scenario: 1. Enter value only in one field (both are required by JSR303 annotations on entity). 2. Click "Submit". Error message appears. 3. Click "Clear".
残值不变。 为什么没有清除地雷?
此外,如果我直截了当,把“Clear”点击回外地。 我检查说,在点击“Clear”纽子之后,部分答复涉及浏览器。 我怀疑它有某种看法。
此外,如果我在实地添加<条码>validator=”#{bean.validate}“,则该编码即进入这一验证。 即使纽特州有<代码>mmediate=“true”属性。 为什么? 是否应当立即对纽特州om进行验证?