Class CascadingValueProvider

  • All Implemented Interfaces:
    CascadingSource, DynamicValueProvider, HasCascadingParent, NodeParser, java.io.Serializable

    public class CascadingValueProvider
    extends FieldValueProvider
    implements HasCascadingParent
    Creates a CascadingValueProvider which provides default values for a prompt based on a value of a parent prompt field.

    The parent prompt field itself must have a FieldValueProvider so that the possible default values can be filtered with a "WHERE" condition in the query.

    For example, a PromptField with a FieldValueProvider pointing to a database field representing countries could be set as a parent for a CascadingValueProvider pointing to a database field representing cities. When the default values are fetched, the value for the country is placed in the "WHERE" condition, thereby only providing the cities in the given country.

    Since:
    7.7
    See Also:
    Serialized Form
    • Constructor Detail

      • CascadingValueProvider

        public CascadingValueProvider​(PromptField parent,
                                      CascadingSource parentSource,
                                      DatabaseField values,
                                      DatabaseField descriptions,
                                      int sortType)
        Initializes a CascadingValueProvider with the given parent, value field and (optionally) description field, as well as the desired sort type.
        Parameters:
        parent - Parent prompt field, may not be null
        parentSource - Provider of the SQL reference name for the parent
        values - Default values' value field
        descriptions - Default values' descriptions field
        sortType - Desired sort type
        Throws:
        java.lang.IllegalArgumentException - if the parent prompt field is null or does not have a FieldValueProvider, or if the values field is null or if the sort type is invalid
        Since:
        7.7
        See Also:
        SortField.ORIGINAL_ORDER, SortField.ASCENDING_ORDER, SortField.DESCENDING_ORDER, CascadingSource, FieldValueProvider
    • Method Detail

      • getParent

        public PromptField getParent()
        Returns the set parent prompt field
        Specified by:
        getParent in interface HasCascadingParent
        Returns:
        Parent prompt field for this cascading provider.
        Since:
        7.7
      • setParent

        public void setParent​(PromptField parent)
        Sets the parent prompt field which is to be used for filtering the default values.
        Specified by:
        setParent in interface HasCascadingParent
        Parameters:
        parent - Parent prompt field, may not be null and must have a FieldValueProvider
        Throws:
        java.lang.IllegalArgumentException - if the parent prompt field is null or does not have a FieldValueProvider,
        Since:
        7.7
      • getSQL

        public java.lang.String getSQL()
        Returns the query which is to be used for fetching the values and optionally descriptions dynamically.
        Overrides:
        getSQL in class FieldValueProvider
        Returns:
        query to be used
        Since:
        7.7
      • setParentSource

        public void setParentSource​(CascadingSource parentSource)
        Sets the parent source for this cascading prompt that will provide the reference name of the parent to use in the generated SQL query.
        Parameters:
        parentSource - parent source which provides the reference name of the parent to use in the query, may not be null
        Throws:
        java.lang.IllegalArgumentException - if the parent source given is null
        Since:
        7.7
      • getParentSource

        public CascadingSource getParentSource()
        Returns the parent source which provides the reference name for the parent prompt when referencing it in the generated SQL query.
        Returns:
        parent source
        Since:
        7.7
      • parseElement

        public NodeParser parseElement​(com.inet.report.parser.XMLTag group,
                                       java.lang.String tag,
                                       org.xml.sax.Attributes atts,
                                       java.util.Map<java.lang.String,​java.lang.Object> parserMap)
                                throws FatalParserException
        FOR INTERNAL USE ONLY FOR INTERNAL USE ONLY Internal method for reading report XML

        Parses an XML node with the given information, and returns either a sub-element which was created as a result, or null if no sub-element was created, i.e. the information was applied to the ReportComponent itself. Note that the parsing is highly tolerant, i.e. exceptions are intercepted and suppressed if at all possible.

        Specified by:
        parseElement in interface NodeParser
        Overrides:
        parseElement in class FieldValueProvider
        Parameters:
        group - XMLTag of the current node to be parsed, or null if there is no such current group. An XMLTag is a group of nodes bundled together, usually it is a Properties node such as CommonProperties, BorderProperties, etc.
        tag - The XMLTag to be parsed
        atts - The set of attributes in the current XMLTag
        parserMap - The map of current Parser.
        Returns:
        The NodeParser sub-element if one needed to be created, or null if none was created.
        Throws:
        FatalParserException - if an exception occurs which causes the report to not be able to be read: causes the abortion of the reading of the report.