Class FieldUtil


  • public final class FieldUtil
    extends java.lang.Object
    Utility class for common operations on fields.
    • Method Detail

      • copyValue

        public static void copyValue​(IntelligentField fromField,
                                     IntelligentField toField)
        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-field
        toField - target-field
      • getFieldValue

        public static java.lang.Object getFieldValue​(IntelligentField fromField)
        Returns the value from the specified field as object.
        Parameters:
        fromField - source-field
        Returns:
        field value as object
      • getJniValueFromLookupField

        public static com.saperion.jni.SaJNIValue getJniValueFromLookupField​(LookupTextField field)
        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

        public static com.saperion.jni.SaJNIValue[] getJniValuesFromLookupField​(LookupTextField field)
        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

        public static java.lang.Object getLookupValue​(LookupTextField field,
                                                      java.lang.String column)
        Gets the value of the specified column of the specified lookup-field..
        Parameters:
        field - the field
        column - the column
        Returns:
        the lookup value
      • resolveFieldLink

        public static FieldUtil.ResolvedFieldLink resolveFieldLink​(java.lang.String link,
                                                                   IntelligentFormView form)
        Resolves a field link.
        Parameters:
        link - the link as String
        form - the form parent form of the field that contains the link
        Returns:
        the resolved field link
      • generateId

        public static java.lang.String generateId​(com.saperion.ngc.iform.xml.EditFieldType field)
        Generates a unique id for an EditFieldType.
        Parameters:
        field - the field to generate an id for
        Returns:
        a unique id for field
      • getParentForm

        public 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.
        Parameters:
        formComponent - component to get the parent form for
        Returns:
        parent form or null
      • getFormatterForDecimalFields

        public static java.text.DecimalFormat getFormatterForDecimalFields​(com.saperion.ngc.iform.xml.EditFieldType field)
        Creates a new DecimalFormat 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 java.lang.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 a DecimalFormat but uses the actual currency-symbol instead of the currency-symbol-placeholder ยค (see DecimalFormat).
        Parameters:
        field - field to create the pattern for
        Returns:
        pattern-string
      • isDateField

        public static boolean isDateField​(IntelligentField field)
        Parameters:
        field - field to check
        Returns:
        true if this field contains values of type Date.
      • isStringField

        public static boolean isStringField​(IntelligentField field)
        Parameters:
        field - field to check
        Returns:
        true if this field contains values of type String.
      • isIntegerField

        public static boolean isIntegerField​(IntelligentField field)
        Parameters:
        field - field to check
        Returns:
        true if this field contains values of type Integer.
      • isBooleanField

        public static boolean isBooleanField​(IntelligentField field)
        Parameters:
        field - field to check
        Returns:
        true if this field contains values of type Boolean.
      • isDoubleField

        public static boolean isDoubleField​(IntelligentField field)
        Parameters:
        field - field to check
        Returns:
        true if this field contains values of type Double.
      • isMultivalueField

        public static boolean isMultivalueField​(IntelligentField field)
        Parameters:
        field - field to check
        Returns:
        true if this field is a multivalue-field