0

Listbox selected...

asked 2009-01-06 17:54:02 +0800

vicnetepc gravatar image vicnetepc
96

I'm using one controle class with AfterCompose with use attribute.
I don't know to take one column of Listbox component of window when
the Listbox is selected.
Who to do it?
thanks...

delete flag offensive retag edit

6 Replies

Sort by ยป oldest newest

answered 2009-01-06 18:37:02 +0800

YamilBracho gravatar image YamilBracho
1722 2

I do not understand what you mean...
Do you mean headers or a whole column data ?

link publish delete flag offensive edit

answered 2009-01-06 18:45:20 +0800

vicnetepc gravatar image vicnetepc
96

updated 2009-01-06 18:47:42 +0800

Hi, YamilBracho.
One column data in Listbox..
It run in zkscript, but i can not in control class.

link publish delete flag offensive edit

answered 2009-01-06 18:55:19 +0800

YamilBracho gravatar image YamilBracho
1722 2

Still no clue...
Well, Would you mind to post your zscript code ?

link publish delete flag offensive edit

answered 2009-01-06 22:49:18 +0800

vicnetepc gravatar image vicnetepc
96

updated 2009-01-06 23:41:14 +0800

my codes; zscript and control class

//zscript
void selecionaItemListaAgenda()
{
//pega o item selecionado / take item selected

List linhaSel = boxPesqAgenda.selectedItem.children;
if (linhaSel != null)
{
//retorna o conteudo de cada coluna
String coluna1 = linhaSel.get(0).label;
String coluna2 = linhaSel.get(1).label;
String coluna3 = linhaSel.get(2).label;
String coluna4 = linhaSel.get(3).label;
String coluna5 = linhaSel.get(4).label;
idAgenda.value=coluna1;
nomeAgenda.value=coluna2;
foneAgenda.value=coluna3;
celularAgenda.value=coluna4;
}
//zscript end

// this code is not compatible in control class....follow:

package AgendaEletronicaMVC.controle;

import AgendaEletronicaMVC.DAO.*;
import AgendaEletronicaMVC.modelo.*;
import com.mysql.jdbc.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
import org.zkoss.zhtml.Messagebox;
import org.zkoss.zk.ui.Components;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.ext.AfterCompose;
import org.zkoss.zul.Button;
import org.zkoss.zul.Window;
import org.zkoss.zul.Tab;
import org.zkoss.zul.Textbox;
import org.zkoss.zul.Listbox;
import org.zkoss.zul.Listcell;
import org.zkoss.zul.Listitem;

public class AgendaControle extends Window
implements AfterCompose
{

private Tab tabCadAgenda;
private Tab tabPesqAgenda;
private Textbox idAgenda;
private Textbox nomeAgenda;
private Textbox foneAgenda;
private Textbox celularAgenda;
private Listbox boxCategAgenda;
private Button botaoIncluirAgenda;
private Button botaoAlterarAgenda;
private Button botaoExcluirAgenda;
private Button botaoLimparAgenda;
private Textbox pqListaAgenda;
private Listbox boxTipoPesqAgenda;
private Listbox boxPesqAgenda; //this is my listbox
private Button botaoLimpaListaPesqAgenda;
private Button botaoAtualizaListaAgenda;

................

public void selecionaItemListaAgenda() throws
InterruptedException, SQLException
{
//pega o item selecionado // take item selected
Listitem item = boxCategAgenda.getSelectedItem();
String descricao = item.getLabel(); //???? IS HERE! HOW TO DO IT?
....

}

......
}

link publish delete flag offensive edit

answered 2009-01-07 01:52:37 +0800

robertlee gravatar image robertlee
561

updated 2009-01-07 01:53:14 +0800

Hi vicente,
You mean you want to call item.getChildren().get(the index of your desired column).getLabel();

In a zk listbox you have following structure:

<listbox >
	<listhead>
		<listheader label="" sort="auto" />
		<listheader label="" sort="auto" />
	</listhead>
	<listitem>
		<listcell label="" />
		<listcell label="" />
	</listitem>
	<listitem>
		<listcell label="" />
		<listcell label="" />
	</listitem>
</listbox>

which means the children of any listitem will be a listcell, you can then access the label there.

Hope this helps,
Robert

link publish delete flag offensive edit

answered 2009-01-07 11:00:48 +0800

vicnetepc gravatar image vicnetepc
96

Hi, Robertlee. Thanks.
I hope your code run in my control class.

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-01-06 17:54:02 +0800

Seen: 405 times

Last updated: Jan 07 '09

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