get selected item from listbox and pass to another window/modal listbox

asked 2016-03-18 09:55:56 +0800

Fahmy gravatar image Fahmy
3 1

updated 2016-03-18 10:05:53 +0800

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'.

Here is my main zul code:

<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">
                    <toolbarbutton tooltiptext="Lihat Detail"
                        onClick="@command('detaildata')" />
<listbox id="testListbox" mold="paging" model="@bind(vm.monitorList)" emptyMessage="Tidak ada data untuk ditampilkan" selectedItem="@bind(vm.selectedMonitor)" PageSize="5" pagingPosition="both">
        <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" />
    <template name="model" var="terpilih">
            <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>

This is my controller code:

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;

    Window WindowUserPopUp;

    Window WindowUser;

    private MonitoringDAO monitorService;

    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;

    public void keluar() {

    public void detaildata(){
        if(selectedMonitor == null){
        Messagebox.show("No data selected!", "Warning", Messagebox.OK, Messagebox.EXCLAMATION);
        Window window = (Window)Executions.createComponents(
                "/WEB-INF/pages/monitoring/monitoringPopUp.zul", this.self, args);

And this is my popup zul (monitoringPopUp.zul):

<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">
            <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"/>
    <template name="model" var="terpilih">
            <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>


delete flag offensive retag edit


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

1 Answer

Sort by ยป oldest newest most voted

answered 2016-03-18 10:06:39 +0800

Darksu gravatar image Darksu
1991 1 4

Hello Fahmy,

A very good example that you can use, can be found at the following url:


Best Regards,


link publish delete flag offensive edit
Your answer
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

1 follower



Asked: 2016-03-18 09:55:56 +0800

Seen: 39 times

Last updated: Mar 18 '16

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