重置错误信息JSF与复位按钮和清除字段[重复] 。

问题描述 投票:0回答:1

我有一个注册表,有以下数据。

名字姓氏年龄电子邮件地址电话密码再输入密码。

现在,如果密码不匹配或年龄是一个文本错误消息显示,我有一个复位按钮,以清除所有的字段,但错误出现后,重新发送按钮不清除消息或字段。

下面是按钮的代码和我的java类中的内容。

<h:commandButton value="Reset" type="reset" action="#{javaBeanTest.reset()} />

在Bean类中

public void reset()
{
    this.foreName = null;
    this.surname = null;
    this.age = 0;
    this.password = null;
    this.confirmPass = null;
    this.email = null;
}

我应该怎么做?字段被设置为空白,但消息仍然存在

jsf xhtml message
1个回答
0
投票

尝试使用 render="@form" 在您的命令按钮中,它会更新表格和其中的错误。你用什么来显示错误信息?

试试这个方法。

<h:commandButton value="Reset" action="#{javaBeanTest.reset()} />    
    <f:ajax render="@form"/>
</h:commandButton>
© www.soinside.com 2019 - 2024. All rights reserved.