Never mind. I found the problem: I had to put the selectManyCheckbox tag inside a facet tag.

So instead of ...

<x:dataTable var="data" value="#{test.dataModel2}">
        <x:selectManyCheckbox id="items" layout="spread">
                <f:selectItems value="#{test.items2}"/>
        </x:selectManyCheckbox>
                
        <h:column>
                <x:checkbox for="items" index="#{test.dataModel2.rowIndex}"/>
        </h:column>
</x:dataTable>

I had to do ...

<x:dataTable var="data" value="#{test.dataModel2}">
        <h:column>
                <f:facet name="header">
                        <x:selectManyCheckbox id="items" layout="spread">
                                <f:selectItems value="#{test.items2}"/>
                        </x:selectManyCheckbox>           
                </facet>
                <x:checkbox for="items" index="#{test.dataModel2.rowIndex}"/>
        </h:column>
</x:dataTable>

Thanks for all the help

Jan


On Fri, 03 Jun 2005 11:24:16 +0200, Jan Bols <[EMAIL PROTECTED]> wrote:

Thanks Srikanth for the reply,

what I'm trying to say is that the state of the checkboxes in the list nested inside the dataTable isn't set at all after clicking the submit button. So I don't think it has anything to do with the fact that the checked items of the second list overwrites the ones in the first list. Also when I adapt my jsf page and only keep the selectManyCheckbox nested inside the dataTable the same happens.

Greetings
Jan

On Thu, 02 Jun 2005 18:32:11 +0200, Srikanth Madarapu <[EMAIL PROTECTED]> wrote:


Also when I add value binding to both lists, f.e. I add
value="test.myList" to both selectManyCheckbox tags, the Test.setMyList
method gets called for the second list, but not for the first one.

Even if it gets called, after submit the state of the fist list will be overwritten with the state from the second list. And you will see the same state on the first list as in the second as they are using the same data in the backing bean.

I cannot tell why the method is not getting called for the first list.



-----Original Message-----
From: Jan Bols [mailto:[EMAIL PROTECTED]
Sent: Thursday, June 02, 2005 8:37 AM
To: MyFaces Discussion
Subject: Re: checkbox> looses state when inside data Table


To put it simple: when I call the page I see the list of checkboxes twice
(once nested in the dataTable, once not nested).

When I click on a checkbox in the first list and I submit the page, the
clicked checkbox isn't checked anymore in the postback.
When I click on a checkbox in the second list and I submit the page, the
clicked checkbox is still checked in the postback(as should be).

Also when I add value binding to both lists, f.e. I add
value="test.myList" to both selectManyCheckbox tags, the Test.setMyList
method gets called for the second list, but not for the first one.

I hope I made it a bit clearer.

Jan


On Thu, 02 Jun 2005 14:22:49 +0200, Srikanth Madarapu
<[EMAIL PROTECTED]> wrote:

What do you mean by loosing state, are they having incorrect state or no
state at all ?

It seems to me that, each of the check boxes is displayed twice and
later check box's status will be stored in your managed bean. I think
after submit you are seeing the same state on the two sets of check
boxes.

-Srikanth

-----Original Message-----
From: Jan Bols [mailto:[EMAIL PROTECTED]
Sent: Thursday, June 02, 2005 7:02 AM
To: users@myfaces.apache.org
Subject: <x:checkbox> looses state when inside dataTable


I have the following form:

<h:form>  
        <x:dataTable var="data" value="#{test.dataModel2}">
                <x:selectManyCheckbox id="items" layout="spread">
                        <f:selectItems value="#{test.items2}"/>
                </x:selectManyCheckbox>
                
                <h:column>
                        <x:checkbox for="items" 
index="#{test.dataModel2.rowIndex}"/>
                </h:column>
        </x:dataTable>
        
        <x:selectManyCheckbox>
                <f:selectItems value="#{test.items2}"/>
        </x:selectManyCheckbox>

        <h:commandButton value="Submit" />
</h:form>

As you can see it contains 2 times the same list of checkboxes and a
submit button. The first list of checkboxes is nested inside a dataTable.
This way I have some control over where the <x:checkbox> items must be
placed. The other list of checkboxes is just a plain selectManyCheckbox.

The problem is that the first list of checkboxes loses state after the
submit, while the second one doesn't (as is the normal behaviour). In
other words the first list doesn't work.

The managed bean test is hooked to this class:

public class Test {
        private Collection items2;
        private DataModel dataModel2;
        
        public Test() {
                items2 = new ArrayList(3);
                items2.add(new SelectItem("200", "Duke's Quarterly", ""));
                items2.add(new SelectItem("202", "Duke's Diet and Exercise 
Journal",
""));
                items2.add(new SelectItem("201", "Innovator's Almanac", ""));

                dataModel2 = new ListDataModel((List) items2);
        }
        public DataModel getDataModel2() {return dataModel2;}
        public void setDataModel2(DataModel dataModel2) {this.dataModel2 =
dataModel2;}
        public Collection getItems2() {return items2;}
        public void setItems2(Collection items2) {this.items2 = items2;}
}

What am I doing wrong here? It seems really difficult to render
checkboxes
inside dataTables.

Jan





Reply via email to