Grids Live Data(urgent)
up
Hi
for live data example, first, you could check the ZK demo, and you could see the source code of how to use Live Grid
i know how use Live Data but it work only on my first Grid but not in the second Grid (inside the first)
if you could get one to work, but not the the second, maybe you have some typo??
or you could show the sample code ?
this is my code:
index.zul
<window apply="mycontroller">
<grid id="listaUtentiId" fixedLayout="true">
<columns>
<column width="25px" />
<column label="Nome" align="center"/>
<column label="Cognome" align="center"/>
<column label="Email" align="center"/>
<column label="Importo Totale" align="center"/>
<column width="25px" />
</columns>
<rows>
<row>
<detail id="detail" fulfill="onOpen" forward="onClick=onTest">
<grid id="listaRichiesteId">
<columns>
<column label="Id Richiesta" align="center"/>
<column label="Data Richiesta" align="center"/>
<column label="Importo" align="center"/>
</columns>
</grid>
</detail>
</row>
</rows>
</grid>
</window>
mycontroller.java
<b >. . .</b>
private Grid listaUtentiId;
private Grid listaRichiesteId;
private Textbox idutenterecord;
private String idutentetextbox;
public void doAfterCompose(Component comp) throws Exception {
super.doAfterCompose(comp);
/**
* Riempie Lista Debitori su utentiList.zul
*/
List<String> model = new ArrayList<String>(mgr.getUsersByDeb());
listaUtentiId.setRowRenderer(new RowRenderer() {
public void render(Row row, Object data) throws Exception {
if (data == null) return;
Object[] _data = (Object[])data;
row.appendChild(detail);
new Label(_data[0].toString()).setParent(row);
new Label(_data[1].toString()).setParent(row);
new Label(_data[2].toString()).setParent(row);
new Label().setParent(row);
String ciccio = _data[3].toString();
row.appendChild(new org.zkoss.zul.Textbox(ciccio));
org.zkoss.zul.Textbox textboxidutente= (org.zkoss.zul.Textbox) row.getChildren().get(5);
idutentetextbox = textboxidutente.getValue();
}
});
ListModel strset = new ListModelList(model);
listaUtentiId.setModel(strset);
comp.addEventListener("onTest", new org.zkoss.zk.ui.event.EventListener() {
public void onEvent(Event event) throws Exception {
int prova = Integer.parseInt(idutentetextbox);
List<String> modell = new ArrayList<String>(ricMgr.getRichiesteByDeb(prova));
listaRichiesteId.setRowRenderer(new RowRenderer() {
public void render(Row row, Object data) throws Exception {
if (data == null) return;
Object[] _data = (Object[])data;
new Label(_data[0].toString()).setParent(row);
new Label(_data[1].toString()).setParent(row);
new Label(_data[2].toString()).setParent(row);
}
});
ListModel ptt = new ListModelList(modell);
listaRichiesteId.setModel(ptt);
}
});
}Error:
GRAVE: >>java.lang.NullPointerException >> at com.aubay.webapp.controller.UserControllerDebitori$2.onEvent(UserControllerDebitori.java:342) >> at org.zkoss.zk.ui.impl.EventProcessor.process0(EventProcessor.java:196) >> at org.zkoss.zk.ui.impl.EventProcessor.process(EventProcessor.java:140) >> at org.zkoss.zk.ui.event.Events.sendEvent(Events.java:284) >> at org.zkoss.zk.ui.event.Events.sendEvent(Events.java:307) >> at org.zkoss.zk.ui.AbstractComponent$ForwardListener.onEvent(AbstractComponent.java:2850) >>...
I get this error because when i call listener my listaRichiesteId is NULL
up
hi
you have to find the Grid "listaRichiesteId" first, you could refer to MVC in ZK
focus on "GenericForwardComposer"
thx for help
now i use GenericForwardComposer and onClick$detail(Event event) method but what u mean with "you have to find the Grid "listaRichiesteId" first"?
i need to load first listaUtentiId for load first Grid and before second Grid (inside the first)everytime i click detail on every record on first grid...it's wrong?
solved. removed fulfil="onOpen" now work
ZK - Open Source Ajax Java Framework
Hi all, i need urgent example for Grid in Grid whit LIVE DATA in all two...because my RowRender work only on first Grid!!!
Thx