0

Problems with ZK

asked 2011-02-04 12:39:21 +0800

wnederhof gravatar image wnederhof
33 2

Hello,

First, allow me to introduce myself. My name is Wouter Nederhof and I am a second year Computer Science student at the University of Groningen, the Netherlands. Besides my study I also own a business company with a few other people, developing medical software.

For the past few months now, I have been trying to learn all about the ZK framework, and I must say that this project is, to say the least, very interesting.

However, I found quite a few difficulties and problems with ZK, and I couldn't find the solutions by googling it, so I decided to post my issues using ZK on the forum.

The first problem I am having is the following:

I created a listbox in ZUL as following:

<listbox id="abc" apply="abc.ABCComposer">
<columns>
...
</columns>
<rows>
<row self="@{each=message}"
style="vertical-align: top;">
<label value="@{message.date}" />
<label value="@{message.author}" />
<label value="@{message.message}"
multiline="true" />
</row>
</rows>
</listbox>

Now, if I put a button on the page that, when the user clicks on the button, it will trigger an event that changes the model of this listbox, then all columns are filled in according to the template. However, if I set the model in the doAfterCompose function in the apply-class, it will remove all columns in the listbox and will replace them with a single column where the toString() value of the objects are presented.

What am I doing wrong here? Should I put the setModel-function elsewhere? Or should I call some kind of initialization function first?

The second problem is the following:

In order to fix the first problem, I have now created a ListitemRenderer (which I consider nothing more than a fast hack to just make it work). However, if I set the Listitemrenderer in the doAfterCompose function and select an item in the Listbox, it tells the apply-class that no items have been selected. That is, for example in the function onSelect$list, getSelectedItem() returns NULL and getSelectedIndex() returns -1. However, when I do NOT set the Listitemrenderer, then this problem will not occur.

What am I doing wrong where? Why won't the selectedItem change anymore after changing the renderer?

I hope someone can answer one or both these questions.

Thanks in advance!

Best regards,

Wouter Nederhof

delete flag offensive retag edit

2 Replies

Sort by ยป oldest newest

answered 2011-02-04 14:28:39 +0800

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

updated 2011-02-04 14:30:48 +0800

Hi Wouter,

first, welcome to the zk forum. ZK is the best choice.

Seems you mix several techniques.

1. take a window component (spaceOwner) around all and apply your composer to this component.
2. a few sample lines for a databinded Listbox:

<!-- DATABINDED LISTBOX -->
				<listbox id="listBoxBranch"
					model="@{controller.branches}"
					selectedItem="@{controller.selectedBranche}" vflex="true"
					width="100%"
					height="100%" 
                                        multiple="false">

					<listhead sizable="true">
						<listheader id="listheader_BranchText"   label="TestHeader"  width="100%" />
					</listhead>

					<listitem self="@{each='branche'}" value="@{branche}"
						forward="onDoubleClick=onDoubleClickedBranchItem">

						<listcell label="@{branche.braBezeichnung}" />

					</listitem>

				</listbox>

That's all. Only you must set the selectedBean and model and the method for onDoubleClickedBranchItem.

You can checkout a complete demo application and debug what is interesting for you.
Try it online http://www.zk-web.de/zksample2/.

best
Stephan

link publish delete flag offensive edit

answered 2011-02-06 10:58:34 +0800

wnederhof gravatar image wnederhof
33 2

Hi,

Think I finally get it now. I didn't used beans, since I come from PHP (and Java SE) and never even heard of Spring before. Guess although I program for quite a long time now, I have to do a lot of research before I understand all the fundamental concepts of Java EE, Spring, Hibernate and ZK.

Thanks!

Wouter

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: 2011-02-04 12:39:21 +0800

Seen: 293 times

Last updated: Feb 06 '11

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