Interface LookupField<F extends LookupField<F>>

    • Method Detail

      • readEndpoint

        default F readEndpoint​(PageableEndpoint<?> endpoint)
        Configure the read endpoint for the lookup. This endpoint tells the lookup where it can go to retrieve the options the user chooses from. This endpoint is a PageableEndpoint and supports different paging strategies.
        Parameters:
        endpoint - the endpoint
        Returns:
        this
      • readEndpoint

        default F readEndpoint​(UnaryOperator<PageableEndpoint<?>> fn)
        Configure the read endpoint for the lookup. This endpoint tells the lookup where it can go to retrieve the options the user chooses from. This endpoint is a PageableEndpoint and supports different paging strategies.
        Parameters:
        fn - function to configure the endpoint
        Returns:
        this
      • getReadEndpoint

        default PageableEndpoint<?> getReadEndpoint()
        Returns:
        the read endpoint
      • findReadEndpoint

        default Optional<PageableEndpoint<?>> findReadEndpoint()
        Returns:
        an optional with read endpoint, or empty
      • hydrateEndpoint

        default F hydrateEndpoint​(Endpoint<?> endpoint)
        Configures the hydration endpoint for the lookup. This endpoint tells the lookup where to can go to retrieve the hydrated option for the current value. This endpoint is used when the component mounts to hydrate the option associated with the stored value.

        This is only necessary when only the option value is being stored in the property as when configured with a valueSelection(). This may be necessary in certain optionSelection() situations when the option being stored is heavily transformed by transformSelection(Mapping[]).

        Parameters:
        endpoint - the hydrate endpoint
        Returns:
        this
      • hydrateEndpoint

        default F hydrateEndpoint​(UnaryOperator<Endpoint<?>> fn)
        Configures the hydration endpoint for the lookup. This endpoint tells the lookup where to can go to retrieve the hydrated option for the current value. This endpoint is used when the component mounts to hydrate the option associated with the stored value.

        This is only necessary when only the option value is being stored in the property as when configured with a valueSelection(). This may be necessary in certain optionSelection() situations when the option being stored is heavily transformed by transformSelection(Mapping[]).

        Parameters:
        fn - a function to configure the hydrate endpoint
        Returns:
        this
      • getHydrateEndpoint

        default Endpoint<?> getHydrateEndpoint()
        Returns:
        the hydrate endpoint
      • findHydrateEndpoint

        default Optional<Endpoint<?>> findHydrateEndpoint()
        Returns:
        an optional with hydrate endpoint, or empty
      • searchable

        default F searchable​(boolean isSearchable)
        Configures the lookup to be searchable or not
        Parameters:
        isSearchable - whether or not searchable
        Returns:
        this
      • searchable

        default F searchable()
        Configures the lookup to be searchable. This allows the user to type text into the select in order to filter the results. If using an API with the standard text query parameters, then use searchableDefaults().
        Returns:
        this
      • isSearchable

        default boolean isSearchable()
        Returns:
        whether or not this lookup is configured as searchable
      • searchableDefaults

        default F searchableDefaults()
        Configures the lookup to be searchable and configures the endpoint to map over the default `q` and `cq` parameters. This is compatible with the standard pattern for searchable endpoints. If the endpoint being searched against supports a non-standard pattern, then searchable(boolean) should be used and the readEndpoint(UnaryOperator) configured with the parameters.
        Returns:
        this
      • notSearchable

        default F notSearchable()
        Configures the lookup to not be searchable. This is the default if searchable() is not used.
        Returns:
        this
      • multi

        default F multi​(boolean isMulti)
        Configures whether or not the lookup supports multi-selection.
        Returns:
        this
      • multi

        default F multi()
        Configures this lookup to support multi-selection. This is useful for situations where the user should be able to select one or more options.

        For configurations where valueSelection() is chosen, the selected options will have their values persisted in an array.

        For configurations where optionSelection() is chosen, the selected options will themselves be stored in an array.

        Returns:
        this
      • notMulti

        default F notMulti()
        Configures this lookup to not support multi-selection.
        Returns:
        this
      • valueSelection

        default F valueSelection()
        Configures the lookup with the LookupField.SelectionTypes.VALUE selection type. This engages behavior that will cause only the selected option's value to be stored within the form state for this field.

        Note, the value of the selected option is driven by the valueKey(String), which defaults to "id".

        Returns:
        this
      • optionSelection

        default F optionSelection()
        Configures the lookup with the LookupField.SelectionTypes.OPTION selection type. This engages behavior that will cause the entire selected option to be stored within the form state for this field.

        Note, the option that is stored may be different from the data selected if this lookup is configured with transformSelection(Mapping[]), as that transforms the selected value before persistence.

        Returns:
        this
      • transformSelection

        default F transformSelection​(Mapping<?>... mappings)
        Configure a set of Mapping to transform the option the user selects before the form state is updated. For LookupField.SelectionTypes.OPTION, this can be used to transform the chosen option into a new structure. For LookupField.SelectionTypes.VALUE, this can be used to map over additional properties from the chosen option outside of the option's value.
        Returns:
        this
      • transformSelection

        default F transformSelection​(List<Mapping<?>> mappings)
        Configure a set of Mapping to transform the option the user selects before the form state is updated. For LookupField.SelectionTypes.OPTION, this can be used to transform the chosen option into a new structure. For LookupField.SelectionTypes.VALUE, this can be used to map over additional properties from the chosen option outside of the option's value.
        Returns:
        this
      • labelKey

        default F labelKey​(String labelKey)
        Sets the name of the label key. Defaults to {@link "name"}. It can contain the template to create more complicated labels. * For example to display the label like `Name (id)` the template like `${name} - (${id})` can be used.
        Parameters:
        labelKey - the label key
        Returns:
        this
      • valueKey

        default F valueKey​(String valueKey)
        Sets the name of the value key. Defaults to {@link "id"}.
        Parameters:
        valueKey - the label key
        Returns:
        this
      • loadingMessage

        default F loadingMessage​(String loadingMessageKey)
        Configure the message to be displayed while the lookup is loading it's options.
        Parameters:
        loadingMessageKey - the label key
        Returns:
        this
      • noOptionsMessage

        default F noOptionsMessage​(String noOptionsMessageKey)
        Configure the message to be displayed when the lookup finds no options.
        Parameters:
        noOptionsMessageKey - the label key
        Returns:
        this
      • selectComponent

        default F selectComponent​(String selectComponentName)
        Sets the name of the React component that will be used for rendering the select input. This is generally used for more advanced lookups that require a more complicated interface.
        Parameters:
        selectComponentName - the modal component name
        Returns:
        this
      • modalSearch

        default F modalSearch​(UnaryOperator<LookupFieldModal<?>> fn)
        Configure this lookup with a modal for more advanced searching. This will result in an additional toggle button being rendered that, upon clicking, will provide the user with a modal that includes a filterable list grid of options. This is primarily used in instances where the text search within the lookup select is not sufficient on its own.

        Note, you can use modalComponent(java.lang.String) to configure a custom React component for the modal, or modalToggleLabel(java.lang.String) to configure the label for the modal toggle button. Lastly, modal search can be disabled again using notModalSearch().

        Parameters:
        fn - a function that further configures the search modal
        Returns:
        this
      • notModalSearch

        default F notModalSearch()
        Disables modal support and remove the Advanced button from the lookup field.
        Returns:
        this