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)
This commit is contained in:
Carlos Ruiz 2020-07-01 15:44:59 +02:00 committed by GitHub
parent fa3e9461e8
commit 11c9ad6c59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 6 deletions

View File

@ -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,19 +229,32 @@ 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("_"))
{
text = text.substring(1);
}
getComponent().setText(text);
}
else
{
getComponent().setText("");
if (curValue == null)
curValue = value;
ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), curValue, null);
fireValueChange(changeEvent);
this.value = null;
}
}
else
{
getComponent().setText("");
}