You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Ma...@sanofi-aventis.com on 2008/09/03 11:29:58 UTC

Problem with checkbox

Hi,

 

I'm having a strange problem with the t:selectBooleanCheckbox component.
I'm using the Ajax4JSF framework as well. So I have a div containing
some form fields, one of them being the checkbox. It has a save button
and a cancel button. To the left of that is a tree with different items.
The tree items are ajax command links which will rerender the div. This
much works fine. The problem is with the checkbox and clicking cancel. 

 

I have 2 items, test1 and test2. The value binding for the checkbox is
set to true for test1 and false for test2. If I click on test1 the form
will show a checked checkbox. Now I click cancel, now I click test2. The
checkbox is still checked, but it should be unchecked. 

 

Running in debug mode and here's what I've found.

 

When I click cancel the decode method gets called on the checkbox and
sets the submitted value to true since it was checked when cancel was
clicked. I've got the immediate set to true so it won't update anything.
Not that it matters since the field gets reset anyway when calling my
modify method. Next I click to modify test2 and when this method gets
called...

 

RendererUtils.class #173

    public static Object getObjectValue(UIComponent component) {

        if (!(component instanceof ValueHolder)) {

            throw new IllegalArgumentException("Component : " +

                getPathToComponent(component) + "is not a ValueHolder");

        }

 

        if (component instanceof EditableValueHolder) {

            Object value = ((EditableValueHolder)
component).getSubmittedValue();

            if (value != null && !NOTHING.equals(value)) {

                return value;

            }

        }

 

        return ((ValueHolder) component).getValue();

    }

 

The call to getSubmittedValue() returns a Boolean set to true. Normally
it should return null and use the value binding.

 

So this is my problem. How can I make it use the value binding?

 

Another point, If I don't click cancel and just click modify on test2
directly it works fine. It's only when I click cancel and then try and
modify the other one.

 

Thanks,

Matt