0

i'm developing a spring project. i'm using jsf java javascript and jquery.

but i have on problem.

t if user check checkbox

How can i this.

i tried this

<script type="text/javascript">
    function ozgur() {
        if(document.getElementById('fikirCheck').checked) {
            document.getElementById("secondPage").setAttribute("rendered",true);

        }else{
            document.getElementById("secondPage").setAttribute("rendered",false);
        }


    };
</script>

checkbox boolean check box.

Thank you for help

lepe
  • 24,677
  • 9
  • 99
  • 108
Who is are
  • 153
  • 2
  • 3
  • 10

2 Answers2

0

Answer

You just cant! The rendered attribute is evaluated at server side by JSF. Thus, when it process the page, it evaluates the component and if the result of rendered is false, the component doest not get processed and does not go to the final html to the client.

Solution:

You can wrap your component to a div and use style: display:none and control it with javascript. Take a look at How to change css display none or block property using Jquery?. That can help you out.

Community
  • 1
  • 1
Bruno
  • 2,889
  • 1
  • 18
  • 25
  • 1
    You can put the `style: display=none` on the component itself to. No need to wrap it (in this usecase) – Kukeltje Dec 15 '16 at 08:26
0

Either you can give rendered flag value directly like

<h:selectBooleanCheckbox value="#{myBean.value}" id="chk" rendered="true"/> 

or from Bean

<h:selectBooleanCheckbox value="#{myBean.value}" id="chk" rendered="#{myBean.isRender}"/>
Albin
  • 1,929
  • 2
  • 14
  • 18