0

Listbox event not fired! Please Help!

asked 2008-11-05 10:23:53 +0800

nat gravatar image nat
195 3

Hi
I have a small zul page for displaying dynamic data (only 45 listitems)... and I want to fire an event when a row is selected.
Everything is fine with the first 10 rows... then... Nothing..
I couldn't understand the event is fired for the first 10 items!.. What's wrong?

My zul page looks like the following:

<listbox id="selectedRows" rows="10" fixedLayout="true">
<listhead>
<listheader width="5%" label="id" sort="auto"/>
<listheader label="class" sort="auto"/>
</listhead>
<zscript>
List standardClasses = facade.getStandardClasses();
</zscript>
<listitem value="Standards" forEach="${ standardClasses }" onDoubleClick="searchWindow.addSelected()" >
<listcell style="padding-bottom: 60px" label="${each.nr} " />
<listcell style="overflow: hidden; padding: 10px" label="${each.txt}" />
</listitem>
</listbox>

Any idea would be welcome! Please urgent help needed!

-nat

delete flag offensive retag edit

12 Replies

Sort by ยป oldest newest

answered 2008-11-05 11:46:04 +0800

windperson gravatar image windperson
415 1

Hi nat,
what is your searchWindow in

onDoubleClick="searchWindow.addSelected()" 

Can you provide more detail information of your code? thx.

link publish delete flag offensive edit

answered 2008-11-05 13:17:15 +0800

nat gravatar image nat
195 3

I guess nobody has an idea about the problem.
Am stucked with this problem. May I shouldn't have choosen ZK for my web-app front-end??

link publish delete flag offensive edit

answered 2008-11-06 00:58:41 +0800

PeterKuo gravatar image PeterKuo
481 2

I see two "10" in your question.
So I guess you can simply remove rows="10".

link publish delete flag offensive edit

answered 2008-11-07 09:23:51 +0800

ziccardi gravatar image ziccardi
321 7

Hi nat-

I tried this in the ZK DEMO:

<window title="My First Window" border="normal" width="200px">
  <listbox id="selectedRows" rows="10" fixedLayout="true">
  <listhead>
  <listheader width="30%" label="id" sort="auto"/>
  <listheader label="class" sort="auto"/>
  </listhead>
  <zscript>
    void msg()
    {
        alert("hello");
    }
     <![CDATA[
     List standardClasses = new ArrayList();
     for (int i = 0; i < 100; i++)
        standardClasses.add("ITEM " + i);
    ]]>
  </zscript>
  <listitem value="Standards" forEach="${ standardClasses }" onDoubleClick="msg()" >
    <listcell style="padding-bottom: 200px" label="1 " />
    <listcell style="overflow: hidden; padding: 10px" label="${each}" />
  </listitem>
  </listbox>
</window>


And it works, even for the latest elements...

link publish delete flag offensive edit

answered 2008-11-07 09:45:36 +0800

nat gravatar image nat
195 3

Bizarre... after removing rows="10", I was able to fire events on all the rows...
Has this something to do with my event?
Thanks Peter Kuo..
-nat

link publish delete flag offensive edit

answered 2008-11-07 10:43:35 +0800

PeterKuo gravatar image PeterKuo
481 2

Because I look in the source code, and found:

	/** Returns the rows. Zero means no limitation.
	 * <p>Default: 0.
	 */
	public int getRows() {
		return _rows;
	}

and

	public String getOuterAttrs() {
		final StringBuffer sb =
			new StringBuffer(80).append(super.getOuterAttrs());

		if (inSelectMold()) {
			HTMLs.appendAttribute(sb, "name", _name);
			HTMLs.appendAttribute(sb, "size",  getRows());

So, I guess it will set a limitation to the size of of listbox.
After all, it's a little debug trick to search special number or character.
Two "10" in the question? Is it only a coincidence? Or it's the clue?

link publish delete flag offensive edit

answered 2008-11-07 10:51:55 +0800

dennis gravatar image dennis
3679 1 6
http://www.javaworld.com....

which version of zk do you have?
I tested ziccardi code in ZK demo, it works in my firefox and IE.
Could you try to test ziccardi's code in you project too .

link publish delete flag offensive edit

answered 2008-11-07 13:36:51 +0800

nat gravatar image nat
195 3

Hi Dennis
I use ZK 3.5.1.
I tested ziccardi code and it worked out very well!
My listbox contains only 45 items. Event fired very well on the first 10 items,... but from the 11th to the 45th item... no way to fire events.
What I can't understand is after removing "rows="10", my problem was solved! Bizarre...
-nat

link publish delete flag offensive edit

answered 2008-11-07 13:52:35 +0800

ziccardi gravatar image ziccardi
321 7

Hi Dennis.

Could it be related to the fact that the rows after the 10th one are not rendered?
However, I don't understand why my code works and Nat's don't...

If this is the reason, I guess that if Nat puts rows="15" than it would work for the first 15 rows...

To Nat: do it works the same way if you use a composer, a renderer and a model (usually I work this way and have no problems)?

link publish delete flag offensive edit

answered 2008-11-07 14:18:44 +0800

nat gravatar image nat
195 3

Hi Ziccardi

>if you use a composer, a renderer and a model (usually I work this way and have no problems)?
I know composer, renderer and model... but could you elaborate more how you use this trilogy?
Maybe I should follow such methodology for developing zk apps.
A sample code will be very useful.
Thanks a lot!
-nat

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-11-05 10:23:53 +0800

Seen: 241 times

Last updated: Nov 07 '08

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