-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hello everyone, I really am new with both zk and java, and just recently learn to show data from database to listbox.
I had no idea to do this. So sorry if the question is not good.
So I want to show details according to '@bind(terpilih.aktivitas)' of selected item from listbox in the main zul to another zul/windowpopup(monitoringPopUp.zul) listbox by clicking the list/item and then click toolbar button with command 'detaildata'.
<window title="Aktivitas Monitoring" id="WindowUser" width="100%" border="normal" apply="org.zkoss.bind.BindComposer" viewModel="@id('vm') @init('com.swamedia.soki.webui.monitoring.MonitoringCtrl')">
<groupbox mold="3d" contentStyle="max-height:350px; overflow:auto;">
<caption label="Hasil Monitoring">
<hbox>
<toolbar>
<toolbarbutton tooltiptext="Lihat Detail"
onClick="@command('detaildata')" />
</toolbar>
</hbox>
</caption>
<listbox id="testListbox" mold="paging" model="@bind(vm.monitorList)" emptyMessage="Tidak ada data untuk ditampilkan" selectedItem="@bind(vm.selectedMonitor)" PageSize="5" pagingPosition="both">
<listhead>
<listheader label="Tanggal" width="8%" />
<listheader label="Waktu" width="8%" />
<listheader label="Aktivitas" width="25%"/>
<listheader label="Hasil Monitoring" />
<listheader label="Status" width="5%"/>
<listheader label="Keterangan" />
</listhead>
<template name="model" var="terpilih">
<listitem>
<listcell label="@bind(terpilih.tgl)"></listcell>
<listcell label="@bind(terpilih.danll)"></listcell>
<listcell label="@bind(terpilih.aktivitas)"></listcell>
<listcell label="@bind(terpilih.hasil)"></listcell>
<listcell label="@bind(terpilih.status)" style="text-align:center;"></listcell>
<listcell label="@bind(terpilih.keterangan)"></listcell>
</listitem>
</template>
</listbox>
</groupbox></window>
package com.swamedia.soki.webui.monitoring;
import com.swamedia.soki.backend.model.Monitoring;
import com.swamedia.soki.backend.model.SecUser;
import com.swamedia.soki.backend.dao.MonitoringDAO;
import com.swamedia.soki.backend.dao.impl.MonitoringDAOImpl;
import com.swamedia.soki.webui.util.GFCBaseCtrl;
public class MonitoringCtrl extends GFCBaseCtrl {
private List<Monitoring> monitorList;
private Monitoring selectedMonitor;
@Wire("#WindowUserPopUp")
Window WindowUserPopUp;
@Wire("#WindowUser")
Window WindowUser;
@WireVariable
private MonitoringDAO monitorService;
@Init
public void initSetup(@ContextParam(ContextType.VIEW) Component view) {
Selectors.wireComponents(view, this, false);
monitorList = monitorService.findAll();
}
public void setMonitorList(List<Monitoring> monitorList) {
this.monitorList = monitorList;
}
public List<Monitoring> getMonitorList(){
return monitorList;
}
public void setSelectedMonitor(Monitoring selectedMonitor) {
this.selectedMonitor = selectedMonitor;
}
public Monitoring getSelectedMonitor() {
return selectedMonitor;
}
@Command
public void keluar() {
WindowUserPopUp.detach();
}
@Command
public void detaildata(){
if(selectedMonitor == null){
Messagebox.show("No data selected!", "Warning", Messagebox.OK, Messagebox.EXCLAMATION);
}else{
Window window = (Window)Executions.createComponents(
"/WEB-INF/pages/monitoring/monitoringPopUp.zul", this.self, args);
window.setClosable(true);
window.doModal();
}
}
}
<window title="Detail Data Monitoring" id="WindowUserPopUp" width="900px" border="normal" apply="org.zkoss.bind.BindComposer"
closable="true" viewModel="@id('vm') @init('com.swamedia.soki.webui.monitoring.MonitoringPopup')">
<listbox mold="paging" model="" selectedItem="" PageSize="10">
<listhead>
<listheader label="Tanggal" width="9%"/>
<listheader label="Waktu" width="8%"/>
<listheader label="Aktivitas" width="25%"/>
<listheader label="Hasil Monitoring"/>
<listheader label="Status" width="6%"/>
<listheader label="Keterangan"/>
</listhead>
<template name="model" var="terpilih">
<listitem>
<listcell label="*this is where i want to show tgl value from selected item"></listcell>
<listcell label="*this is where i want to show danll value from selected item"></listcell>
<listcell label="*this is where i want to show aktivitas value from selected item"></listcell>
<listcell label="*this is where i want to show hasil value from selected item"></listcell>
<listcell label="*this is where i want to show status value from selected item"></listcell>
<listcell label="*this is where i want to show keterangan value from selected item"></listcell>
</listitem>
</template>
</listbox>
</window>
Thanks....
Hello Fahmy,
A very good example that you can use, can be found at the following url:
http://emrpms.blogspot.gr/2012/06/mvvm-modal-windowpass-parameter-and.html
Best Regards,
Darksu
Asked: 2016-03-18 09:55:56 +0800
Seen: 51 times
Last updated: Mar 18 '16
ZK drang and drop and databinding [closed]
Create Crud of a User that has a collection of books
Create a Zk session variable with a menu
Using databinding in menupopup
ZK Clustering, Session Replication Question [closed]
Problem binding values to a composite component
How can i load a constant in .zul
set selectedItem of list in viewmodel - cleaner way? [closed]
to @Darksu, thank you so much for your answer, i can't post comment at your answer since i don't have enough point, I'll read your link.. :)
Fahmy ( 2016-03-18 10:11:54 +0800 )edit