From 11c9ad6c5943b4a9c7490f5f52fbb14157922cba Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Wed, 1 Jul 2020 15:44:59 +0200 Subject: [PATCH] IDEMPIERE-1052 Improve Performance using Search instead of Table/Table Direct (#148) Integrate patch from Heng Sin --> Fix Copy Record issue (handling of invalid value) --- .../adempiere/webui/editor/WSearchEditor.java | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WSearchEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WSearchEditor.java index 04b22310f6..11769acbb8 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WSearchEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WSearchEditor.java @@ -55,6 +55,7 @@ import org.compiere.model.X_AD_CtxHelp; import org.compiere.util.CLogger; import org.compiere.util.DisplayType; import org.compiere.util.Env; +import org.compiere.util.NamePair; import org.zkoss.zk.au.out.AuScript; import org.zkoss.zk.ui.Component; import org.zkoss.zk.ui.Executions; @@ -228,17 +229,30 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value @Override public void setValue(Object value) { + Object curValue = this.value; this.value = value; if (value != null && !"".equals(String.valueOf(value))) - { - String text = lookup.getDisplay(value); + { + NamePair namePair = lookup.get(value); + if (namePair != null) + { + String text = namePair.toString(); - if (text.startsWith("_")) + if (text.startsWith("_")) + { + text = text.substring(1); + } + getComponent().setText(text); + } + else { - text = text.substring(1); + getComponent().setText(""); + if (curValue == null) + curValue = value; + ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), curValue, null); + fireValueChange(changeEvent); + this.value = null; } - - getComponent().setText(text); } else {