public Listitem crearFilas(Object objeto, Component componente) throws Exception { Listitem fila = new Listitem(); final Maestro_manual maestro_manual = (Maestro_manual) objeto; fila.appendChild(new Listcell(maestro_manual.getId_manual() + "")); fila.appendChild(new Listcell(maestro_manual.getManual() + "")); fila.appendChild( new Listcell( Utilidades.getNombreElemento( maestro_manual.getTipo_manual(), "tipo_manual", getServiceLocator()))); fila.appendChild( new Listcell( Utilidades.getNombreElemento( maestro_manual.getTipo_moneda(), "tipo_moneda", getServiceLocator()))); Hlayout hlayout = new Hlayout(); fila.setStyle("text-align: justify;nowrap:nowrap"); Toolbarbutton toolbarbutton = new Toolbarbutton("Editar"); toolbarbutton.setImage("/images/editar.gif"); toolbarbutton.setTooltiptext("Editar registro"); toolbarbutton.addEventListener( Events.ON_CLICK, new EventListener<Event>() { @Override public void onEvent(Event arg0) throws Exception { mostrarDatos(maestro_manual); } }); hlayout.appendChild(toolbarbutton); toolbarbutton = new Toolbarbutton("Eliminar"); toolbarbutton.setImage("/images/borrar.gif"); toolbarbutton.setTooltiptext("Eliminar registro"); toolbarbutton.addEventListener( Events.ON_CLICK, new EventListener<Event>() { @Override public void onEvent(Event arg0) throws Exception { Messagebox.show( "Esta seguro que desea eliminar este registro? ", "Eliminar Registro", Messagebox.YES + Messagebox.NO, Messagebox.QUESTION, new org.zkoss.zk.ui.event.EventListener<Event>() { public void onEvent(Event event) throws Exception { if ("onYes".equals(event.getName())) { eliminarDatos(maestro_manual); buscarDatos(); } } }); } }); hlayout.appendChild(toolbarbutton); Listcell listcell = new Listcell(); listcell.appendChild(hlayout); fila.appendChild(listcell); return fila; }
@Override public void setTooltiptext(String tooltiptext) { super.setTooltiptext(tooltiptext != null ? tooltiptext.replaceAll("[&]", "") : null); }
public void cari() throws Exception { Connection conn = getConn(); try { PerusahaanDAO dao = new PerusahaanDAOImpl(conn); List<Perusahaan> list = dao.gets((Kecamatan) cmbKecamatan.getSelectedItem().getValue()); lstHasil.getItems().clear(); int no = 1; for (final Perusahaan p : list) { Listitem item = new Listitem(); item.setValue(p); item.appendChild(new Listcell(p.getNamaPerusahaan())); item.appendChild(new Listcell(p.getNamaPimpinan())); item.appendChild( new Listcell( p.getAlamatJalan() + ", " + p.getKota() + " Telp: " + p.getTelp() + " Fax: " + p.getFax())); Toolbarbutton btnDetail = new Toolbarbutton(); btnDetail.setId("btnDetail" + (no++)); btnDetail.setImage("/img/detail.png"); btnDetail.setTooltiptext("Klik di sini untuk Detail dan Perubahan data"); btnDetail.addEventListener( "onClick", new EventListener() { public void onEvent(Event event) throws Exception { // panggil form edit Window win = (Window) Executions.createComponents("/zul/admin/editPerusahaan.zul", null, null); Textbox txtIdPerusahaan = (Textbox) win.getFellow("txtIdPerusahaan"); txtIdPerusahaan.setValue(p.getId()); win.doModal(); cari(); } }); Toolbarbutton btnHapus = new Toolbarbutton(); btnHapus.setId("btnHapus" + no++); btnHapus.setImage("/img/delete.png"); btnHapus.setTooltiptext("Klik untuk mengahapus Perusahaan"); btnHapus.addEventListener( "onClick", new EventListener() { public void onEvent(Event event) throws Exception { if (Messagebox.show( "Hapus?", "Konfirmasi", Messagebox.YES | Messagebox.NO, Messagebox.QUESTION) == Messagebox.YES) { Connection connDel = getConn(); try { PerusahaanDAO daoDel = new PerusahaanDAOImpl(connDel); daoDel.delete(p.getId()); cari(); } catch (Exception ex) { Messagebox.show(ex.getMessage()); } finally { connDel.close(); } } } }); Listcell cellAksi = new Listcell(); cellAksi.appendChild(btnDetail); cellAksi.appendChild(new Space()); cellAksi.appendChild(btnHapus); item.appendChild(cellAksi); lstHasil.appendChild(item); } } catch (Exception ex) { Messagebox.show(ex.getMessage()); } finally { conn.close(); } }