0

Listbox and foreach, again....

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

cvotava gravatar image cvotava
3

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" >
<listhead>
<listheader label="${c:l('title')}"/>
</listhead>


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

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 +0000

hideokidd gravatar image hideokidd
750 1 2

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

Hi,

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"?>
<zk>
<zscript>
<![CDATA[ //@IMPORT
import org.zkoss.zk.ui.event.EventListener;
]]>
<![CDATA[  //@DECLARATION
void init(Label label,String site){
	//do initialization
	addListener(label,site);
}
void addListener(Label label,String site){
	label.addEventListener("onClick", new EventListener(){
		public void onEvent(Event e) throws Exception { 
			Executions.sendRedirect(site);
		}
	});
}
]]>
</zscript>
<window title="new page title" border="normal">
<listbox>
<listhead>
<listheader label="website"/>
</listhead>
<listitem>
<listcell>
<label value="google" onCreate='init(self,"http://www.google.com")'/>
</listcell>
</listitem>
<listitem>
<listcell>
<label value="zk" onCreate='init(self,"http://www.zkoss.org")'/>
</listcell>
</listitem>
</listbox>
</window>
</zk>

Thanks.

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: 2009-03-24 19:12:22 +0000

Seen: 312 times

Last updated: Mar 25 '09

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