0

ListBox selectedItems

asked 2010-03-15 13:14:17 +0800

dickdastardly gravatar image dickdastardly
168 1 5

Shouldnt i be able to select multiple items from a listbox using something like this?

<listbox model="@{referenceData.allergies}" checkmark="true"
	multiple="true" selectedItems="@{children.allergyType}">
	<listitem self="@{each='childAllergy'}" value="@{childAllergy}">
		<listcell label="@{childAllergy.description}" />
	</listitem>
</listbox>

and NOT have to write any java code to get the selected items back set in a Set?

my session attribute children.allergyType is a java Set
shouldnt this be getting populated from the selected items from the listbox?

delete flag offensive retag edit

13 Replies

Sort by ยป oldest newest

answered 2010-03-16 00:03:07 +0800

dickdastardly gravatar image dickdastardly
168 1 5

why is'nt this easy?

why does zk have a listbox component that has multiple attribute you simply have to set to true to allow
multiple selections from the displayed this...

However it appears to be so hard to retrieve those selected items back into your data model!

why is'nt there a demo/docs showing how to do this?

do you really have to write java controller to be able to do this for every multiple selection listbox
within an app?

link publish delete flag offensive edit

answered 2010-03-17 02:50:10 +0800

iantsai gravatar image iantsai
2755 1

I'm not sure the question you have, so maybe I should verify it at first.

you have a variable named "children" which is an attribute stored in session, this "children" has a property named "allergyType"( with setter& getter methods).

now you want to bind this "children"'s "allergyType" to listbox's selectedItems, which means every time App User changed his selection of this listbox, the setAllergyType(Set<Listitem>) will be triggered.

is that true?

link publish delete flag offensive edit

answered 2010-03-17 13:18:46 +0800

dickdastardly gravatar image dickdastardly
168 1 5

That is an accurate description of my problem

allergyType is a java Set<AllergyType> and I would like each and every selected allergy type to be populated in this set

I've read that zk listboxes do not support multiple selections and you have to write some java code for type converters and extend listbox itslf to make this work

Cheers

DD

link publish delete flag offensive edit

answered 2010-03-17 22:07:43 +0800

iantsai gravatar image iantsai
2755 1

I think implement a converter is what you need to implement as least, I know this part could be a good feature that ZK should implement, maybe you can shoot a feature request.
(I think this is also a good Sample Code to be putted into ZK Studio's sample code)

link publish delete flag offensive edit

answered 2010-03-18 00:03:37 +0800

dickdastardly gravatar image dickdastardly
168 1 5

Do you know of a good example of how to develop a Converter?

Especially if there is one for ListBox

link publish delete flag offensive edit

answered 2010-03-18 02:55:55 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

Samples for converters can be found at RoberPic's sample page here .

best
Stephan

link publish delete flag offensive edit

answered 2010-03-18 11:16:12 +0800

robertpic71 gravatar image robertpic71
1275 1

Check also this thread for the "ListitemsConverterV3".
And follow the whole thread for the "community-patches".

This Typeconverter manage n:m relations.

/Robert

link publish delete flag offensive edit

answered 2010-03-18 22:56:56 +0800

xnguyen gravatar image xnguyen
30 3

I can testify that the robertpic71's ListitemsConverterV3 worked for me. I just wish it was included in the next ZK release.

link publish delete flag offensive edit

answered 2010-03-19 03:21:13 +0800

dickdastardly gravatar image dickdastardly
168 1 5

Thanks to everyone that has replied on this thread
and finally after a week of trying selectedItems i get my listbox multiple selections working

As I am using zk 5 ee i would have expected this to be working now.

Not wanting to sound ungrateful or anything, zk has such a brilliant look and feel, but this "feature"
of not being able to get multiple selections is a real depressing problem.

I am trying to keep my application as light as possible and having to write my own java code (or actually cut and paste from
robertpic71 :-)) to get the desired result is hurting me.

Thanks again to everyone

DD

link publish delete flag offensive edit

answered 2010-03-21 23:25:59 +0800

iantsai gravatar image iantsai
2755 1

I'll send this feature request to ZK Team, I think it's a general requirement.

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: 2010-03-15 13:14:17 +0800

Seen: 3,514 times

Last updated: May 26 '20

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