通过JavaScript引用JSF控件的属性 [英] Reference JSF control's attributes via JavaScript

查看:57
本文介绍了通过JavaScript引用JSF控件的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以从JavaScript引用JSF h:inputText控件的required属性?这是一个不能使用AJAX的页面,我想根据另一个文本字段中的值设置required属性.

Is it possible to reference the required attribute of a JSF h:inputText control from JavaScript? This is a page that can't use AJAX and I'd like to set the required attribute based on the value in another text field.

推荐答案

我想根据另一个文本字段中的值设置所需的属性.

I'd like to set the required attribute based on the value in another text field.

然后只需在required属性中检查那个.

Then just check that in the required attribute.

例如什么时候让它取决于其他字段是否填写:

E.g. when you want to let it depend on whether the other field is filled in or not:

<h:inputText value="#{bean.input1}" binding="#{input1}" />
<h:inputText value="#{bean.input2}" required="#{not empty input1.value}" />

或者当它必须是一个特定值时,例如"foo".

Or when it has to be a specific value instead, e.g. "foo".

<h:inputText value="#{bean.input1}" binding="#{input1}" />
<h:inputText value="#{bean.input2}" required="#{input1.value == 'foo'}" />

保持简单.

这篇关于通过JavaScript引用JSF控件的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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