zk listbox getItems() returns null for item.getValue() if not scrolled fully

asked 2014-06-28 15:09:41 +0800

sarbpreet gravatar image sarbpreet

Listbox : <listbox id="roleListbox" width="98%" checkmark="true" multiple="true" rows="12"/>

The list box is loaded with approximately 50 values using ListModelList(passedList) Requirement is to preselect the values which were saved earlier.

Process: Iterating over roleListbox.getItems() and then checking if the value was selected by getting item.getValue().

But it throws a NullPointerException at item.getValue() for the items which are not yet visible to screen. Paging is NOT being used. If the list is scrolled fully once then NO error is received.

Checked with setPreloadSize(int sz) which is deprecated but doesn't help.

How can I ensure that all items passed in the ListModelList are loaded right away?

delete flag offensive retag edit


Thanks Chill. Solved the issue. Couldnt upvote your answer as it requires 15 points :).

sarbpreet ( 2014-06-29 12:07:57 +0800 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2014-06-28 21:26:10 +0800

chillworld gravatar image chillworld flag of Belgium
5322 4 9

you have to render your list fully before you can do that.

Listbox has a method renderAll(); that you need to trigger.

Take attention, this is done at client side so if you do this in the method where you have to preselect the items it will fail.(you need at least 1 interaction with client before it's good)

If you don't find it, show me code and I'll try to figure it out.

Greetz chill.

link publish delete flag offensive edit
Your answer
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

1 follower



Asked: 2014-06-28 15:09:41 +0800

Seen: 13 times

Last updated: Jun 28 '14

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