Package com.saperion.ngc.util
Class FieldUtil
java.lang.Object
com.saperion.ngc.util.FieldUtil
Utility class for common operations on fields.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic void
copyValue
(IntelligentField fromField, IntelligentField toField) Copies the value from one field to another.static String
generateId
(com.saperion.ngc.iform.xml.EditFieldType field) Generates a unique id for anEditFieldType
.static Object
getFieldValue
(IntelligentField fromField) Returns the value from the specified field as object.static String
getFormatPatternForDecimalFields
(com.saperion.ngc.iform.xml.EditFieldType field) Returns a pattern-string that can be used to format a ZK NumberInputElement.static DecimalFormat
getFormatterForDecimalFields
(com.saperion.ngc.iform.xml.EditFieldType field) Creates a newDecimalFormat
instance for use in the specified field.static com.saperion.jni.SaJNIValue
Create a SaJNIValue from the value that is entered in the specified lookup-field.static com.saperion.jni.SaJNIValue[]
Create a SaJNIValue from the value that is entered in the specified lookup-field.static Object
getLookupValue
(LookupTextField field, String column) Gets the value of the specified column of the specified lookup-field..static IntelligentFormView
getParentForm
(org.zkoss.zk.ui.Component formComponent) Returns the parent form of the specified component or null, if the component is not part of a form.static boolean
isBooleanField
(IntelligentField field) static boolean
isDateField
(IntelligentField field) static boolean
isDoubleField
(IntelligentField field) static boolean
isIntegerField
(IntelligentField field) static boolean
static boolean
isStringField
(IntelligentField field) static FieldUtil.ResolvedFieldLink
resolveFieldLink
(String link, IntelligentFormView form) Resolves a field link.
-
Method Details
-
copyValue
Copies the value from one field to another. This method throws an IllegalArgumentException if the field-types of the two fields do not match.- Parameters:
fromField
- source-fieldtoField
- target-field
-
getFieldValue
Returns the value from the specified field as object.- Parameters:
fromField
- source-field- Returns:
- field value as object
-
getJniValueFromLookupField
Create a SaJNIValue from the value that is entered in the specified lookup-field. Will throw an IllegalArgumentException if the value could not be handled.- Parameters:
field
- the field- Returns:
- SaJNIValue with proper type and value
-
getJniValuesFromLookupField
Create a SaJNIValue from the value that is entered in the specified lookup-field. Will throw an IllegalArgumentException if the value could not be handled.- Parameters:
field
- the field- Returns:
- SaJNIValue with proper type and value
-
getLookupValue
Gets the value of the specified column of the specified lookup-field..- Parameters:
field
- the fieldcolumn
- the column- Returns:
- the lookup value
-
resolveFieldLink
Resolves a field link.- Parameters:
link
- the link as Stringform
- the form parent form of the field that contains the link- Returns:
- the resolved field link
-
generateId
Generates a unique id for anEditFieldType
.- Parameters:
field
- the field to generate an id for- Returns:
- a unique id for field
-
getParentForm
Returns the parent form of the specified component or null, if the component is not part of a form.- Parameters:
formComponent
- component to get the parent form for- Returns:
- parent form or null
-
getFormatterForDecimalFields
public static DecimalFormat getFormatterForDecimalFields(com.saperion.ngc.iform.xml.EditFieldType field) Creates a newDecimalFormat
instance for use in the specified field. The formatter will be localized for the current locale and will contain the currency- symbol for the specified field (if the field is a currency-field).
This method can only be used from within ZK-context.- Parameters:
field
- field to create the formatterfor- Returns:
- new
DecimalFormat
-
getFormatPatternForDecimalFields
public static String getFormatPatternForDecimalFields(com.saperion.ngc.iform.xml.EditFieldType field) Returns a pattern-string that can be used to format a ZK NumberInputElement. The pattern is based on aDecimalFormat
but uses the actual currency-symbol instead of the currency-symbol-placeholder ยค (seeDecimalFormat
).- Parameters:
field
- field to create the pattern for- Returns:
- pattern-string
-
isDateField
- Parameters:
field
- field to check- Returns:
- true if this field contains values of type
Date
.
-
isStringField
- Parameters:
field
- field to check- Returns:
- true if this field contains values of type
String
.
-
isIntegerField
- Parameters:
field
- field to check- Returns:
- true if this field contains values of type
Integer
.
-
isBooleanField
- Parameters:
field
- field to check- Returns:
- true if this field contains values of type
Boolean
.
-
isDoubleField
- Parameters:
field
- field to check- Returns:
- true if this field contains values of type
Double
.
-
isMultivalueField
- Parameters:
field
- field to check- Returns:
- true if this field is a multivalue-field
-