You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@empire-db.apache.org by do...@apache.org on 2024/05/29 14:30:15 UTC
(empire-db) branch master updated: EMPIREDB-422 TextInputControl added FormatOption FRACTION_DIGITS
This is an automated email from the ASF dual-hosted git repository.
doebele pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/empire-db.git
The following commit(s) were added to refs/heads/master by this push:
new 0e103974 EMPIREDB-422 TextInputControl added FormatOption FRACTION_DIGITS
0e103974 is described below
commit 0e103974daa76d22c50cd8251d59229942c841dd
Author: Rainer Döbele <do...@apache.org>
AuthorDate: Wed May 29 16:30:11 2024 +0200
EMPIREDB-422
TextInputControl added FormatOption FRACTION_DIGITS
---
.../java/org/apache/empire/jsf2/controls/TextInputControl.java | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/TextInputControl.java b/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/TextInputControl.java
index cd73c21f..89b4dc99 100644
--- a/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/TextInputControl.java
+++ b/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/TextInputControl.java
@@ -60,6 +60,8 @@ public class TextInputControl extends InputControl
public static final String DATE_FORMAT = "date-format:";
public static final String DATE_FORMAT_ATTRIBUTE = "format:date";
+ public static final String FRACTION_DIGITS = "fraction-digits:";
+
private Class<? extends HtmlInputText> inputComponentClass;
public TextInputControl(String name, Class<? extends HtmlInputText> inputComponentClass)
@@ -297,7 +299,7 @@ public class TextInputControl extends InputControl
}
if (dataType == DataType.DECIMAL || dataType == DataType.FLOAT)
{ // Dezimal oder Double
- NumberFormat nf = getNumberFormat(dataType, vi.getLocale(), column);
+ NumberFormat nf = getNumberFormat(dataType, vi, column);
return nf.format(value);
}
if (dataType == DataType.DATE || dataType == DataType.DATETIME || dataType == DataType.TIMESTAMP)
@@ -515,8 +517,9 @@ public class TextInputControl extends InputControl
return DataType.UNKNOWN;
}
- protected NumberFormat getNumberFormat(DataType dataType, Locale locale, Column column)
+ protected NumberFormat getNumberFormat(DataType dataType, ValueInfo vi, Column column)
{
+ Locale locale = vi.getLocale();
if (column == null)
return NumberFormat.getNumberInstance(locale);
// Column is supplied
@@ -530,7 +533,7 @@ public class TextInputControl extends InputControl
Object groupSep = column.getAttribute(Column.COLATTR_NUMBER_GROUPSEP);
nf.setGroupingUsed(groupSep != null && ObjectUtils.getBoolean(groupSep));
// Fraction Digits?
- Object fractDigit = column.getAttribute(Column.COLATTR_FRACTION_DIGITS);
+ Object fractDigit = getFormatOption(vi, FRACTION_DIGITS, Column.COLATTR_FRACTION_DIGITS);
if (fractDigit != null)
{ int fractionDigits = ObjectUtils.getInteger(fractDigit);
int length = (int)column.getSize();