通过第一个文本框的AJAX禁用数据验证后,第二个文本字段 [英] disabling second text field after data validation through ajax of first text field

查看:203
本文介绍了通过第一个文本框的AJAX禁用数据验证后,第二个文本字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试用JSF 2.0,我遇到了一个情景是这样的。

As I was experimenting with JSF 2.0 , i came across a scenario like this .

我有两个文本字段 - 基于第一场Ajax调用使用燃煤的输入

I have two text fields - based on input of first field an ajax call is fired using

<f:ajax ... />

在响应又回来了,我再使第二个文本字段..但我想基于第一个字段值某些服务器端验证禁用第二个文本字段。

After the response is back I am re rendering the second text field ..but i want to disable the second text field based on some server side validation of first field value.

我不希望使用样式禁用基于其上的验证后,豆被设置了第三个属性来设置。

I don't want to set the disabled using style based on a third property which is being set in the bean after validation.

有没有其他办法。

在此先感谢

推荐答案

第一个输入组件视图绑定绑定属性和使用的 UIInput#的isValid() 在第二个输入字段的禁用属性。它会返回如果验证失败给定的输入组件。

Bind the first input component to the view by binding attribute and use UIInput#isValid() in the disabled attribute of the second input field. It will return false if validation has failed on the given input component.

<h:inputText binding="#{input1}" value="#{bean.input1}">
    <f:validator validatorId="yourValidator" />
    <f:ajax event="blur" render="input2" />
</h:inputText>
<h:inputText id="input2" value="#{bean.input2}" disabled="#{!input1.valid}" />

这篇关于通过第一个文本框的AJAX禁用数据验证后,第二个文本字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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