Listbox and foreach, again....

asked 2009-03-24 19:12:22 +0800

cvotava gravatar image cvotava

Hi all,
Firstly, Thank to Zk team for this great framework.

I would like to display a listbox of items and doing some operations with this list.
I would like a button to add a new item, and a button to delete multiple selection.
Also, I would like to go to a specific page by clicking on the item.
I successfully done the display, and the new button, and the delete button. It works fine.

But I didn't success to go to a specific page by clicking on the item.

Every time I catch an event and put some breakpoints in my code, I can see the item with null value, empty values, or bad values.
In this case, the redirection works fine by clicking on an item , but the value of the item is empty. I don't know why... So I can't use it as parameter and do a redirection.
So I am letting the code a little bit clean, hoping someone has an idea how to use my selected object to do operations, like redirecting to another page.

Here is a part of my zk page:

<listbox id="shows" model="@{showListModel.shows}" checkmark="true" multiple="true" >
<listheader label="${c:l('title')}"/>

<listitem self="@{each=show}">
<label value="@{show.title}" forward="onEditShow(${self})" />

Here is a part of my controller code:

public void onEditShow (Event e) {
Component c=(Component)e.getData() ;
sendRedirect(Webflow.EDITSHOW,"showTitle="+c.getId()) ;

delete flag offensive retag edit

1 Reply

Sort by ยป oldest newest

answered 2009-03-25 02:02:24 +0800

hideokidd gravatar image hideokidd
750 1 2

updated 2009-03-25 02:03:10 +0800


I can't find out the correct answer, just providing suggestion

1.Try this

Component c=(Component)e.getTarget() ;

2.My example

<?page title="new page title" contentType="text/html;charset=UTF-8"?>
import org.zkoss.zk.ui.event.EventListener;
void init(Label label,String site){
	//do initialization
void addListener(Label label,String site){
	label.addEventListener("onClick", new EventListener(){
		public void onEvent(Event e) throws Exception { 
<window title="new page title" border="normal">
<listheader label="website"/>
<label value="google" onCreate='init(self,"http://www.google.com")'/>
<label value="zk" onCreate='init(self,"http://www.zkoss.org")'/>


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




Asked: 2009-03-24 19:12:22 +0800

Seen: 312 times

Last updated: Mar 25 '09

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