Skip to content Skip to sidebar Skip to footer

How To Get A Value Of Jsf Selectbooleancheckbox By Using Javascript?

I save in my selectBooleanCheckbox only boolean values in a backingbean which named 'bean'. To set a label for this checkbox in my JSF xhtml page i´m using a JSF outputText compon

Solution 1:

You should give a unique ID to the components and then try getting these values in java script by their ID , Also you can use 'onclick' to call the java script method. for ex:

<h:selectBooleanCheckbox id="firstBox"class="extern" value="#{bean.booleanValue1}"       onclick="update(this)"/>
<h:outputText id="firstOutput" value="My Labeltext1"/>

And your java script function would look something like this:

functionupdate(val){
         var box= document.getElementById("firstBox");
         var outPut = document.getElementById("firstOutput");
        var boxValue = box.value;
        var outPutValue = outPut.value;
 }

Post a Comment for "How To Get A Value Of Jsf Selectbooleancheckbox By Using Javascript?"