0

Default listitem renderers behave strangely in zk3.5.2

asked 2008-12-10 17:45:12 +0800

cvarona gravatar image cvarona
554 1 6

Hi,

I've tried the following in the online demo:

<zk>
	<zscript><![CDATA[

SimpleListModel levels = new SimpleListModel( new String[]{  "LOW", "MIDDLE", "HIGH" } );
]]></zscript>
	<listbox id="list" width="200px" rows="10" model="${levels}" />
<zscript>
<![CDATA[
for( li: list.getItems() ) {
    alert( "" + li.getValue() );
}
]]>
</zscript>
</zk>

The first item seems to get rendered always with null value; if we however allow the page to fully get loaded first, like this:
<zk>
	<zscript><![CDATA[

SimpleListModel levels = new SimpleListModel( new String[]{  "LOW", "MIDDLE", "HIGH" } );
]]></zscript>
	<listbox id="list" width="200px" rows="10" model="${levels}" />
<button label="klikk!" onClick='showItems()' />
<zscript>
<![CDATA[
void showItems() {
for( li: list.getItems() ) {
    alert( "" + li.getValue() );
}
}
]]>
</zscript>
</zk>

it works fine.

With kind regards

César Varona

delete flag offensive retag edit

1 Reply

Sort by » oldest newest

answered 2008-12-11 04:54:07 +0800

henrichen gravatar image henrichen
3869 2
ZK Team

It is about timing. When the "levels" is assigned into model, the Listitem is not created "immediately". Rather, it is created on an internal event "later".

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: 2008-12-10 17:45:12 +0800

Seen: 138 times

Last updated: Dec 11 '08

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