0

Multiple selection in listbox with databinding

asked 2012-01-05 09:00:26 +0800

Neus gravatar image Neus
1415 14

Hi,
I have a listbox with attributes multiple="true" and checkmark="true".
When the listbox is created (with no items because items only appears when a button is clicked) the checkmark to select multiple items is displayed in the listheader.
But when I fill the listbox with data (binder.loadComponent(LBFicheros)) the checkbox disappears and a radiobutton is displayed in each row. I checked if the listbox for some reason changes to multiple="false" but is not so, listbox is still multiple.

Any idea why is this happening?

My listbox:

<listbox  id="LBFicheros" multiple="true" checkmark="true" width="100%" vflex="1" mold="paging" autopaging="true"  model="@{VentanaFicheros$composer.listaBeans}">
          <listhead sizable="true">
                    ...
          </listhead>
          <listitem id="fila" self="@{each=ServidorBean}" value="@{ServidorBean}">
                    <listcell label="@{ServidorBean.Tabla}" tooltiptext="@{ServidorBean.Tabla}" style="text-align:left;white-space:nowrap"/>
                     ....
         </listitem>
</listbox>

delete flag offensive retag edit

15 Replies

Sort by ยป oldest newest

answered 2012-02-21 11:09:43 +0800

Neus gravatar image Neus
1415 14

Finally yes!It's because ListModelList. With Java List multiple is set automatically.
Thank you Matze

link publish delete flag offensive edit

answered 2012-02-21 10:21:11 +0800

Matze2 gravatar image Matze2
773 7

updated 2012-02-21 10:21:28 +0800

I haven't used ListModelList directly yet, I always pass an ordinary Java List (ArrayList).
I think you need to set multiple flag on that ListModelList before you provide it to the ZK binding.

link publish delete flag offensive edit

answered 2012-02-21 10:14:19 +0800

Neus gravatar image Neus
1415 14

Yes sorry.
Here the code:

private ListModelList<ServidorBean> _items = new ListModelList<ServidorBean>();
public List<ServidorBean> getItems () {
	return _items;
}

link publish delete flag offensive edit

answered 2012-02-21 09:50:50 +0800

Matze2 gravatar image Matze2
773 7

This is the method for the binding

selectedItems="@bind(vm.selected)"

I wanted to know how you bind
model="@load(vm.items)"

link publish delete flag offensive edit

answered 2012-02-21 08:35:04 +0800

Neus gravatar image Neus
1415 14

Yes I use ZK 6.
This is my getItems():

private Set <ServidorBean> selected;
public Set<ServidorBean> getSelected() {
	return selected;
}

link publish delete flag offensive edit

answered 2012-02-17 13:43:22 +0800

Matze2 gravatar image Matze2
773 7

updated 2012-02-17 13:46:04 +0800

Yes, this looks ok. Do you use ZK6 release?
And how does your getItems() looks like?

link publish delete flag offensive edit

answered 2012-02-17 12:29:27 +0800

Neus gravatar image Neus
1415 14

Ok, I reproduce your listbox:

<listbox id="LBFicheros" multiple="true" model="@load(vm.items)" selectedItems="@bind(vm.selected)">

I remove the paging and the checkmark="true".
And I can't even select multiple items. I press CTRL key and click various items but selection change instead of select all items.
So, my question is...If it works for you..Maybe there's something wrong (that I can't see) with my getter, setter and the instance of selected? Could anyone confirm me that they are ok??

I repeat that setting multiple to listmodellist works.

link publish delete flag offensive edit

answered 2012-02-17 12:06:32 +0800

Matze2 gravatar image Matze2
773 7

updated 2012-02-17 12:07:49 +0800

Things changed during the ZK6 development. Currently my multi-selection listboxes look like the following:

<listbox multiple="true"
	selectedItems="@bind(vm.selectedEntries)"
	model="@load(vm.entries)">

This works with ZK6 release, as far as I remember (cannot check that currently).
As mentioned in another post today, I cannot help with "checkmark" feature.

link publish delete flag offensive edit

answered 2012-02-17 11:18:25 +0800

Neus gravatar image Neus
1415 14

updated 2012-02-17 11:22:26 +0800

I'm changing to ZK6 binding.
Matze2 said that with ZK6 Bind if selectedItems are bind multiple="true" is set automatically.
I tried it and multiple="true"wasn't set.
So I hope some of you can help me finding what I'm not doing well:
This is my listbox:

<listbox nonselectableTags="*" id="LBFicheros" multiple="true" checkmark="true" mold="paging" autopaging="true" model="@load(vm.items)" selectedItems="@bind(vm.selected)">

As you can see I'm binding selectedItems
Then, this is my java code
private Set <ServidorBean> selected;
public Set<ServidorBean> getSelected() {
       System.out.println("Entra en getSelected");
	return selected;
}
public void setSelected(Set<ServidorBean> selected){
	System.out.println("Entra en setSelected");
	this.selected = selected;
}

With this code multiple selection is not enabled and radiobuttons are shown instead of checkboxes.

If I set multiple="true" in the ListModelList it works OK but I understood (maybe I'm wrong) that it is not necessary if selectedItems are binded.

link publish delete flag offensive edit

answered 2012-01-30 08:58:57 +0800

Neus gravatar image Neus
1415 14

Thank you! I fixed it using the converter!

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2012-01-05 09:00:26 +0800

Seen: 1,424 times

Last updated: Feb 21 '12

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More