I am using JSF2 and Java to build a web application. I want to build a form like the one at the picture below:
As suggested by amorfis, the idea of using Ajax here is not the best solution, as you will do a call to your server for a client-side manipulation.
The best solution is to use Javascript to hide your component(s). For example, if all your labels and input texts are nested in a component, you can do that:
...