JSF: dynamically change form

I want to create a form that dynamically changes the visible components depending on the state of other components.

For example ... There are several text fields and some flags, and if the user activates a certain flag, a group of other input elements appears.

Can I do this with JSF 2.0 + Tomahawk or do I need to get another library? And how can I do this? It won’t work without AJAX, right?

Thanks in advance!

0
source share
1 answer

Ajax is a convenient way to do this, and JSF 2.0 comes with ajax.

Here is an example:

<h:selectOneRadio value="#{a7.myCheckbox.state}"> <f:selectItem itemLabel="#{bundle.yes}" itemValue="1"/> <f:selectItem itemLabel="#{bundle.no}" itemValue="0"/> <f:ajax render="uawGroup"/> </h:selectOneRadio> <h:panelGroup id="uawGroup" layout="block"> <h:outputText value="#{bundle.wichmed}" rendered="#{a7.myCheckbox.state == 1}"/> <h:inputText value="#{}" id="myInput" rendered="#{a7.myCheckbox.state == 1}"/> </h:panelGroup> 

h:panelGroup will be displayed when you click yes in h:selectOneRadio (itemValue == 1). Initially, it is 0 (set to bean "a7").

h:panelGroup acts like a shell, since you can update components with ajax, which are actually displayed on the page ( h:outputText and h:inputText not initially displayed).

+4
source

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


All Articles