> 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