JSF jsValueChangeListener with checkbox

Did anybody try to create using JavaServerFaces, a checkBox and a textBox, and when the checkBox is unchecked the textbox should disable immediatly?

I've tried and it works fine in mozilla but in IE the checkbox doesn't disable immediatly, just after a second click on the page. Does anybody know what's wrong ?

Thanks

[340 byte] By [veveua] at [2007-11-27 7:00:13]
# 1
How have you implemented it? You should add onchange="this.form.submit();" to the checkbox component. This invokes a piece of Javascript which submits the parent form on change of the checkbox.
BalusCa at 2007-7-12 18:50:54 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

this is my code:

<t:selectBooleanCheckbox disabled="#{someBean.disabled}" id="checkBoxId" onchange="this.form.submit()" value="#{someBean.checkValue}">

<t:jsValueChangeListener for="myTextBox" expressionValue="if ($srcElem.checked) { $destElem.disabled=false } else {$destElem.disabled=true}"/>

</t:selectBooleanCheckbox>

<t:inputText id="myTextBox"

value="#{someBean.textBoxValue}"

size="3"

maxlength="3"

required="true">

<f:validateLongRange minimum="0"/>

</t:inputText>

Can anyone try this scenario and check if it works in IE ?

Thanks

veveua at 2007-7-12 18:50:54 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

Oh, you're talking about the Tomahawk component. Take a look on their mailing list and eventually report a bug. Maybe there's something wrong in the generated Javascript -if any, take a look in the generated source yourself.

I was expecting that you're using the valueChangeListener of the h:selectBooleanCheckbox.

BalusCa at 2007-7-12 18:50:54 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
is there another way to do this using jsf without jsValueChangeListener ?
veveua at 2007-7-12 18:50:54 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
I already have told something about a h:selectBooleanCheckbox with a valueChangeListener.
BalusCa at 2007-7-12 18:50:54 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6

I haven't used the jsValueChangeListener, but a little investigation suggests that it works entirely on the client side. So in this case I suspect that the onchange attribute you added to the selectBooleanCheckbox is interfering with the jsValueChangeListener.

See http://myfaces.apache.org/tomahawk/javascriptListener.html for more information.

RaymondDeCampoa at 2007-7-12 18:50:54 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 7
Yes, the onchange attribute there is useless. But even if I remove it it doesn't work. I can't believe I can't find someone who had this problem, or someone who created a checkbox that disables a textbox in jsf !!!!!Any example would help me a lot, thanks.
veveua at 2007-7-12 18:50:54 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 8
Like I said, use a selectBooleanCheckbox with a normal valueChangeListener (not jsValueChangeListener as this is likely causing the problems). You can use the rendered attribute of the textbox to show/hide it.
BalusCa at 2007-7-12 18:50:54 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 9
ok, thx, i'll try.
veveua at 2007-7-12 18:50:54 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...