From e5f304ddb913e00b4969ba145093826a85ff839e Mon Sep 17 00:00:00 2001 From: redchris Date: Fri, 25 Mar 2011 23:47:49 -0500 Subject: [PATCH] BF [3058780] WNumberEditor allow only BigDecimal https://sourceforge.net/tracker/?func=detail&aid=3058780&group_id=176962&atid=955896 -- please review --- .../adempiere/webui/editor/WNumberEditor.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WNumberEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WNumberEditor.java index 9f30bc4005..ba979ce62e 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WNumberEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WNumberEditor.java @@ -41,6 +41,9 @@ import org.zkoss.zk.ui.event.Events; * @version $Revision: 0.10 $ * * @author Low Heng Sin + * @author Cristina Ghita, www.arhipac.ro + *
  • BF [3058780] WNumberEditor allow only BigDecimal + * @see https://sourceforge.net/tracker/?func=detail&aid=3058780&group_id=176962&atid=955896 */ public class WNumberEditor extends WEditor implements ContextMenuListener { @@ -48,7 +51,7 @@ public class WNumberEditor extends WEditor implements ContextMenuListener public static final int MAX_DISPLAY_LENGTH = 20; - private BigDecimal oldValue; + private Object oldValue; private int displayType; @@ -129,8 +132,15 @@ public class WNumberEditor extends WEditor implements ContextMenuListener { if (Events.ON_CHANGE.equalsIgnoreCase(event.getName()) || Events.ON_OK.equalsIgnoreCase(event.getName())) { - BigDecimal newValue = getComponent().getValue(); - if (oldValue != null && newValue != null && oldValue.equals(newValue)) { + Object newValue = getComponent().getValue(); + + BigDecimal bd = new BigDecimal(newValue.toString()); + if (displayType == DisplayType.Integer) + newValue = new Integer(bd.intValue()); + else + newValue = bd; + if (oldValue != null && newValue != null && oldValue.equals(newValue)) + { return; } if (oldValue == null && newValue == null) {