Show/hide another input fields using h:selectBooleanCheckbox

后端 未结 3 562
猫巷女王i
猫巷女王i 2020-12-09 19:06

I am using JSF2 and Java to build a web application. I want to build a form like the one at the picture below:

\

3条回答
  •  旧时难觅i
    2020-12-09 19:17

    Use in the checkbox and give the component containing the input fields a rendered attribute which depends on the checkbox's state. No need for another JS code clutter.

    
        

    The above example binds the checkbox to the view, you can of course also bind it to a boolean bean property, you can then remove the not empty check from the rendered attribute.

                
    
    ...
    
                
    

    See also:

    • How to find out client ID of component for ajax update/render? Cannot find component with expression "foo" referenced from "bar"
    • Why do I need to nest a component with rendered="#{some}" in another component when I want to ajax-update it?

提交回复
热议问题