membuat komponen combobox zk

Membuat komponen combobox menggunakan zk framework

Bismillah

q> buat file cobaCombobox.zul


<zk>
 <window apply="org.zkoss.bind.BindComposer"
 viewModel="@id('vm')@init('com.ipi.zk7.mywebzk7.CobaComboboxVM')"
 validationMessages="@id('vmsgs')">
 <label value="Pilih Pekerjaan :"/>
 <separator/>
 <combobox selectedItem="@bind(vm.job)">
 <comboitem label="Karyawan" value="karyawan" />
 <comboitem label="Pegawai" value="pegawai" />
 <comboitem label="Buruh" value="buruh" />
 <comboitem label="Lain-lain" value="lain" />
 </combobox>

 <button onClick="@command('simpan')" label="Tes" />

 </window>
</zk>

q> buat file CobaComboboxVM.java


package com.ipi.zk7.mywebzk7;

import org.zkoss.bind.annotation.Command;
import org.zkoss.zul.Messagebox;

public class CobaComboboxVM {

 private String job;

 public String getJob() {
 return job;
 }

public void setJob(String job) {
 this.job = job;
 }

@Command
 public void simpan(){
 Messagebox.show("Job = " + job);
 }

}

q> Hasil :

Selection_015

Selection_016

Alhamdulillah

Advertisements

membuat radio dalam radiogroup zk

Membuat komponen radio dalam radiogroup menggunakan zk framework

Bismillah

q> buat file cobaRadio.zul


<zk>
 <window apply="org.zkoss.bind.BindComposer"
 viewModel="@id('vm')@init('com.ipi.zk7.mywebzk7.CobaRadioVM')"
 validationMessages="@id('vmsgs')">
 <label value="Pilih Gender :"/>
 <separator/>
 <radiogroup selectedItem="@bind(vm.gender)" >
 <radio label="Pria" value="pria"/>
 <separator/>
 <radio label="Wanita" value="wanita"/>
 </radiogroup>
 <separator />
 <button onClick="@command('simpan')" label="Tes" />

 </window>
</zk>

q> buat file CobaRadioVM.java


package com.ipi.zk7.mywebzk7;

import org.zkoss.bind.annotation.Command;
import org.zkoss.zul.Messagebox;

public class CobaRadioVM {

 private String gender;

public String getGender() {
 return gender;
 }

public void setGender(String gender) {
 this.gender = gender;
 }

 @Command
 public void simpan(){
 Messagebox.show("Gender = " + gender);
 }

}

q> Hasil

Selection_013

Selection_014

membuat checkbox mvvm zk zkoss

Membuat checkbox sederhana pada framework zk (zkoss) menggunakan teknik mvvm

q> Buat file zul -> cobaCheckbox.zul


<zk>
 <window apply="org.zkoss.bind.BindComposer"
 viewModel="@id('vm')@init('com.ipi.zk7.mywebzk7.CobaCheckboxVM')"
 validationMessages="@id('vmsgs')">

 <checkbox onCheck="@command('pilih', checked = self.checked) " />


 </window>
</zk>

q> Buat file zul -> cobaCheckboxVM.java


package com.ipi.zk7.mywebzk7;

import org.zkoss.bind.annotation.BindingParam;
import org.zkoss.bind.annotation.Command;
import org.zkoss.bind.annotation.NotifyChange;
import org.zkoss.zul.Messagebox;

public class CobaCheckboxVM {

 @NotifyChange({"cek"})
 @Command
 public void pilih(@BindingParam("checked") boolean isPicked){
 Messagebox.show("Pilih = " + isPicked);
 }

}

q> Hasil

Selection_011

Selection_012