输入字段即使清除后仍会获取局部值 [英] Input fields get local values even after clearing

查看:162
本文介绍了输入字段即使清除后仍会获取局部值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些使用保存"按钮提交的表单中的输入字段,还有一个清除"按钮,使用清除"方法清除输入字段,该方法使用setSubmittedValue(");来清除值.

I have a few input fields in a form which are submitted using Save button and there is a Clear button to clear the input fields using a clear method which clears the values using setSubmittedValue("");

顶部有一个selectonemenu,带有一个valueChangeListener,它调用backing bean中的方法以为selectonemenu的某些值添加一组额外的输入字段.(此字段具有ajax)

There is a selectonemenu on the top with a valueChangeListener which calls a method in backing bean to add a set of extra input fields for certain value of selectonemenu.(This field has ajax)

首先,我在输入字段中输入一些值(无效),然后单击保存",以使验证失败并显示错误消息. 然后,我单击清除"以清除输入字段,然后将其清除.

First I enter some values(invalid) on the input fields and click Save so that the validation fails and displays error messages. Then I click Clear to clear the input fields and they clear.

现在,如果我单击selectonemenu来更改其值,则输入字段将显示我输入的无效值.

Now if I click on selectonemenu to change its value, the input fields display the invalid values that I entered.

有什么办法可以解决这个问题?

Is there any way to get around this issue?

推荐答案

您已使用空字符串而不是null设置了提交的值.这样,它将在渲染过程中显示,而不是局部值.但是,在随后的请求中,它将再次变为null,而将显示本地值.

You've set the submitted value with an empty string instead of null. This way it will be displayed during render instead of the local value. However, on the subsequent request it becomes null again and the local value will be displayed instead.

清除按钮应已调用 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆