JSF reference attributes via JavaScript

Is it possible to associate a requiredJSF control attribute h:inputTextwith JavaScript? This is a page that cannot use AJAX, and I would like to set the attribute requiredbased on the value in another text box.

+1
source share
3 answers

I would like to set the required attribute based on the value in another text box.

Then just check that in the attribute required.

eg. if you want it to depend on whether another field is filled in or not:

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

Or, when it should be a specific value, for example, "Foo".

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

Keep it simple.

+3
source

" " JSF Javascript. , Javascript.

, JSF Javascript, JSF. , JSF, .

( JSP JSTL... , .)

+2

, . Java Script , JSF .

, , ajax push , - . , ​​ iceFaces, ​​. java script.

+1
source

Source: https://habr.com/ru/post/1777540/


All Articles