0

How to use AnnotateDataBinder for Listbox?????

asked 2011-05-04 04:54:38 +0800

Vikrant gravatar image Vikrant
69

updated 2011-05-04 04:55:19 +0800

can we load data from Listbox to bean class by calling saveAll() When we select listitem

more info:
i have list box with binding

it works well for other components e.g. texbox,intbox

delete flag offensive retag edit

2 Replies

Sort by » oldest newest

answered 2011-05-05 07:26:23 +0800

caclark gravatar image caclark
1753 2 5
http://clarktrips.intltwi...

Look for examples in the Developer's Reference and look at the Javadoc for the selectedItem attribute.

link publish delete flag offensive edit

answered 2011-05-09 10:51:05 +0800

LuisVelez gravatar image LuisVelez
12

I hope this is what you want

<?page title="Tipo de Documentos" contentType="text/html;charset=UTF-8"?>
<zk>
<style>
.GridLayoutNoBorder tr.z-row td.z-row-inner, tr.z-row
.z-cell,div.z-grid { border: none; overflow: hidden; zoom: 1;
background: white; border-top: none; border-left: none;
border-right: none; border-bottom: none; }
</style>
<include src="index.jsp"/>
<div align ="center">
<window id="win" border="none" apply="com.sireax.views.TipoDocsView" width="600px" closable="false" position="center">
<groupbox mold="3d" closable="false">
<caption label="Tipos de Documentos" style="font-weight: bold;">
</caption>
<groupbox mold="3d" closable="false">
<grid sclass="GridLayoutNoBorder" fixedLayout="true" style="border:0px">
<rows>
<row align="center">
<hbox>
<vbox>
<label value="Nuevo Tipo de Documento" style="font-weight: bold;" />
<textbox id="nombre" width="350px" maxlength="70" />
</vbox>
<vbox>
<label value="Activo?" style="font-weight: bold;" />
<listbox id="activo" mold="select" width="60">
<listitem label="Si" value="1" selected="true" />
<listitem label="No" value="0" />
</listbox>
</vbox>
</hbox>
</row>
<row align="center">
<hbox>
<image id="btn_new" src="/images/document_new.png" width="32px" height="30px" tooltiptext="Limpiar" style="cursor:pointer" />
<image id="guardar" src="/images/floppy_disk_48.png" width="32px" height="30px" tooltiptext="Guardar" style="cursor:pointer" />
</hbox>
</row>
</rows>
</grid>
</groupbox>
</groupbox>
<groupbox mold="3d" closable="false" >
<caption label="Listado de Tipos de Documentos" style="font-weight: bold;">
<button id="btn_update" image="/images/Refresh_16x16.png" tooltiptext="Actualizar" />
<space />
<button id="btn_print" image="/images/btn_print2_16x16.gif" tooltiptext="Imprimir Listado" />
<space />
<button id="btn_refresh" image="/images/update.gif" tooltiptext="Recargar lista" />
</caption>
<listbox mold="paging" multiple="false" checkmark="true" pagingPosition="both" model="@{win$composer.allTipoDocs}" selectedItem="@{win$composer.selected}" id="listbox">
<listhead sizable="true">
<listheader label="Tipo Documento" sort="none" image="/images/create_doc.gif" align="left" />
<listheader label="Activo?" sort="none" image="/images/home_blue16x16.gif" align="center"/>
</listhead>
<listitem self="@{each='tdocs'}" value="@{tdocs}">
<listcell label="@{tdocs.descripcion}"></listcell>
<listcell label="@{tdocs.activo,converter}" ></listcell>
</listitem>
</listbox>
</groupbox>
</window>
</div>
</zk>

My Composer

public class TipoDocsView extends GenericForwardComposer {

private List allTipoDocs;
private TipoDocs selected;
private TipoDocs td;
private TipoDocsJpaController tdjpa = new TipoDocsJpaController();
private Window win;
private AnnotateDataBinder binder;
private Listbox listbox;
private Listbox activo;
private Textbox nombre;
private Tabbox listado;
private boolean accion = true;

@Override
public void doAfterCompose(Component comp) throws Exception {
super.doAfterCompose(comp);
allTipoDocs = tdjpa.findTipoDocsEntities("");
listbox.addEventListener(Events.ON_DOUBLE_CLICK, new EventListener() {

public void onEvent(Event event) throws Exception {
onClick$btn_update();
}
});
binder = new AnnotateDataBinder(comp);
binder.loadAll();
}

public void onClick$guardar() {
if (accion) {
td = new TipoDocs();
td.setDescripcion(nombre.getText());
td.setEstadoReg(0);
td.setActivo(1);
String a = td.getActivo() == 2 ? "Si" : "No";
td.setUsername("root");
tdjpa.create(td);
Util.showMessage("Se ha procesado el nuevo registro!");
onClick$btn_new();
onClick$btn_refresh();
} else {
td = selected;
td.setDescripcion(nombre.getText());
td.setActivo(Integer.parseInt((String) activo.getSelectedItem().getValue()));
try {
tdjpa.edit(td);
accion = true;
listbox.setVisible(true);
onClick$btn_new();
onClick$btn_refresh();
Util.showMessage("Se ha actualizado el registro!");
} catch (Exception ex) {
onClick$btn_new();
Util.showError(ex);
Util.showError("No se completó la operación");
}
}
}

public void onClick$btn_update() {
if (selected == null) {
Util.showError("Debe seleccionar un registro de la lista.");
return;
}
activo.setSelectedIndex(selected.getActivo() == 1 ? 0 : 1);
nombre.setText(selected.getDescripcion());
listbox.setVisible(false);
accion = false;
}

public void onClick$btn_new() {
..........................
}

public void onClick$btn_refresh() {
allTipoDocs = tdjpa.findTipoDocsEntities("");
binder.loadAll();
}

public void setSelected(TipoDocs selected) {
this.selected = selected;
}

public TipoDocs getSelected() {
return selected;
}

public List getAllTipoDocs() {
return allTipoDocs;
}
}

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

Follow

RSS

Stats

Asked: 2011-05-04 04:54:38 +0800

Seen: 677 times

Last updated: May 09 '11

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