Question

I was working in Richfaces 4 where i had a requirement that, there's a checkbox & if someone checks it, the boolean value should be stored in a boolean variable in the backing bean without the form being submitted. And according to the value of that variable in backing bean, a text box should be rendered. The coding is somewhat like this:-

<h:selectBooleanCheckbox id="test" onclick="jsRender()" onchange="document.getElementById('formName:test').checked == true ? #{bean.setChecked(true)} : #{bean.setChecked(false)}" />

<a4j:jsFunction name="jsRender" render="@form" />

<h:inputText id="textBox" value="bean.Something" rendered="#{bean.checked}"/>

As far as I know, until the form is submitted, the value of checkbox is not stored in the backing bean. But since I need it to change before Form submission, I have used that condition in the 'onchange' attribute. But the problem is that, the ternary condition is not getting executed, only the el expressions are executing, so I am getting a true as well false no matter if i 'check' or 'uncheck'. I think the syntax is wrong. I need help with the correct syntax.

Thanks in advance :)

Was it helpful?

Solution

To solve this issue I used something like this :-

<selectBooleanCheckbox id="test" value="bean.something">
<a4j:ajax event="change" render="div_name" execute="@this">
</selectBooleanCheckbox>

And this solution worked for me.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top