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()) ;
}
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.
Asked: 2009-03-24 19:12:22 +0100
Seen: 310 times
Last updated: Mar 25 '09