-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3719602
By: nobody
hello,
i am new to zk but i am quiet familiar with java.
i just created a list box, which content i create by a ContentProvider-Controller (mybe you know it from jface). anyway, i just tried to add an eventListener to the listBox:
listBox.addEventListener("onSelect", myEventListener);
i implemented the onEvent-Method in my EventListener-Class but no event is passed to it, when i click an item in the listBox.
i also tried "onClick" as well as add
a eventListener to every listItem, but nothing works.
how can this be?
isAsap() returns true.
tanks a lot for your help.
tim
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3719849
By: henrichen
This is strange. Can you post a reduced but complete code that will replicate your issue?
A typical event handler for Listbox is "onSelect".
/henri
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3722587
By: nobody
hello, thanks for answering.
here ist a some code of my class TabViewer.
private Listbox list;
private RgItemListener itemListener;
//those elements come from my modell
private Object[] elements;
public TabViewer(ITabPanel tabPanel){
this.tabPanel = tabPanel;
this.itemListener = new RgItemListener( this );
this.list = new Listbox();
this.list.addEventListener("onSelect",this.itemListener );
this.tabPanel.appendChild(this.list);
}
public void show(){
for(Object element : this.elements){
Listitem item = new Listitem(this.labelProvider.getName(element));
item.addEventListener("onSelect",this.itemListener );
this.list.appendChild(item);
//this.tabPanel.appendChild(new Separator());
}
}
I tried adding the listener to both, the listbox and its items. adding it only to the listbox or the item works neither.
in my onEvent-Method is only a System.out-Call !
thanks a lot
tim
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3723584
By: henrichen
There should be no need to set the onSelect on the Listitem. Remove that code away.
Can I also take a look of the listener code? If I can replicate the issue here, it would be easier for me to solve it.
/henri
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3724630
By: nobody
hello,
maybe its because miy listbox is a child of a tabpanel, so that the tabpanels onSelect, if there is one, is called before the listbox-onSelect-event?
anyway, here is the code of my eventlistener:
public class RgItemListener implements EventListener {
private TabViewer tv;
public RgItemListener(TabViewer tv){
this.tv = tv;
}
public boolean isAsap() {
// TODO Auto-generated method stub
return true;
}
public void onEvent(Event arg) {
System.out.println("###Target: " + arg.getTarget());
}
}
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3725416
By: henrichen
The code you give me is not a complete working set :).
However, I kind of patching it to complete trying not to change your code struture.
It works without problem.
It has nothing to do with the listbox in tabpanel, either. You have to somehow try to reduce your code and make it replicate your issue that I can test and debug it here.
The following is my working test code based on yours. Maybe you can modify it to make it replicate your issue :).
<zk>
<zscript><![CDATA[
class TabViewer {
private Listbox list;
private RgItemListener itemListener;
//those elements come from my model
private String[] elements = {"elment1","elment2","elment3"};
public TabViewer(Tabpanel tabPanel){
this.tabPanel = tabPanel;
this.itemListener = new RgItemListener( this );
this.list = new Listbox();
this.list.addEventListener("onSelect",this.itemListener );
this.tabPanel.appendChild(this.list);
}
public void show(){
for(int j=0; j < elements.length; ++j){
Listitem item = new Listitem(elements[j]);
this.list.appendChild(item);
//this.tabPanel.appendChild(new Separator());
}
}
public class RgItemListener implements EventListener {
private TabViewer tv;
public RgItemListener(TabViewer tv){
this.tv = tv;
}
public boolean isAsap() {
// TODO Auto-generated method stub
return true;
}
public void onEvent(Event arg) {
alert("list selected:"+arg.getTarget());
}
}
}
]]></zscript>
<tabbox>
<attribute name="onSelect"><![CDATA[
Tabpanel panel = self.getSelectedPanel();
if (panel.getChildren().isEmpty()) {
new TabViewer(panel).show();
}
]]></attribute>
<tabs>
<tab label="tab1"/>
<tab label="tab2"/>
</tabs>
<tabpanels>
<tabpanel id="panel1"/>
<tabpanel id="panel2"/>
</tabpanels>
</tabbox>
</zk>
/henri
Asked: 2006-05-08 21:26:52 +0800
Seen: 3,627 times
Last updated: May 12 '06