I have a boolean(primitive) variable in my bean. I need its value to be true or false depending on the radio button selected by user.
I am implementing JSF radio buttons in two different columns of the same row of a jsf datatable.
It is a requirement that i use radio buttons in two columns of the same row.
Now, i have to make sure just one of the buttons id selected for a row.
So my approach is ,
i am using one radio button mapped to the bean and the other radio button as a dummy.
<h:column>
<h:selectOneRadio id="mixtas" value="#{bean.mixtas}">
<f:selectItem itemValue="true"></f:selectItem>
</h:selectOneRadio>
</h:column>
<h:column>
<h:selectOneRadio id="exclusi" >
<f:selectItem itemValue="true"></f:selectItem>
</h:selectOneRadio>
</h:column>
And i am handling the select just one functionality using jquery
$('input[id*="mixtas"]').live("click",function(){
var $index = this.id.split(':')[2]; \\to identify the row index
var $id = $index+":exclusi:0"; \\generating id for other radio button
$('table[id$="'+$id+'"]').attr("checked",false); \\ to make the other radio false
});
$('input[id*="exclusi"]').live("click",function(){
var $index = this.id.split(':')[2]; \\ to identify the row index
var $id = $index+":mixtas:0"; \\generating id for other radio button
$('input[id$="'+$id+'"]').attr("checked",false); \\ to make the other radio false
});
The functionality works . Atleast half of it (i am still working on the rest).
But the issue is .
If i the mixtas radio button is unchecked and i try to proceed to another page.
It gives error “Property mixtas cannot be set to null“.
Is there any way to assign it a value false rather than null. Maybe in jquery or through bean.
Any suggestions please ….
Thanks In advance.
From your previous questions I assume that you are using JSF 2.0. Then you could get the desired behavior without custom javascript: