From 05730e876e54a32e9ca7cae38e1554941e736d56 Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Tue, 24 Feb 2009 02:31:12 +0000 Subject: [PATCH] [ 2610044 ] Can't save Shipments - reset zero to null if it is not in list --- .../adempiere/webui/component/Combobox.java | 17 ++++++++++ .../webui/editor/WTableDirEditor.java | 34 ++++++++++++++----- 2 files changed, 43 insertions(+), 8 deletions(-) diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/component/Combobox.java b/zkwebui/WEB-INF/src/org/adempiere/webui/component/Combobox.java index 64b0175301..04f2557d9f 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/component/Combobox.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/component/Combobox.java @@ -99,6 +99,23 @@ public class Combobox extends org.zkoss.zul.Combobox } } + /** + * + * @param value + * @return boolean + */ + public boolean isSelected(Object value) + { + if (value == null) + return false; + + Comboitem item = getSelectedItem(); + if (item == null) + return false; + + return item.getValue().equals(value); + } + /** Returns RS_NO_WIDTH|RS_NO_HEIGHT. */ protected int getRealStyleFlags() { diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WTableDirEditor.java b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WTableDirEditor.java index 76fe236f79..02ab0875ec 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WTableDirEditor.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WTableDirEditor.java @@ -174,27 +174,45 @@ ContextMenuListener, IZoomableEditor } return retVal; } - + public void setValue(Object value) { if (value != null && (value instanceof Integer || value instanceof String)) { - getComponent().setValue(value); - - if (getComponent().getSelectedIndex() == -1 && lookup != null) + + getComponent().setValue(value); + if (!getComponent().isSelected(value)) { - if (isReadWrite()) + if (isReadWrite() && lookup != null) lookup.refresh(); + Object curValue = oldValue; oldValue = value; refreshList(); + + //still not in list, reset to zero + if (!getComponent().isSelected(value)) + { + if (value instanceof Integer && (Integer)value == 0) + { + getComponent().setValue(null); + if (curValue == null) + curValue = value; + ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), curValue, null); + super.fireValueChange(changeEvent); + oldValue = null; + } + } + } + else + { + oldValue = value; } } else { getComponent().setValue(null); - } - - oldValue = value; + oldValue = value; + } } @Override