Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    How to invalidate the displayValue cache for a ListGridField

    I have a ListGridField that uses an optionDataSource with a special optionOperationId and optionCriteria. The problem is that when I change the optionCriteria the displayValue no longer shows up correctly. Instead, the valueField displays. If I switch back to the previous criteria the displayValue appears. If I start editing the record the correct displayValue appears in the SelectItem, but not when editing ends the valueField reappears.

    I think what is happening is that the initial fetch populates a static valueMap which is not cleared and refetched when the optionCriteria is changed. I thought I saw an api to invalidateDisplayValueCache or something like that, but I can't seem to find it.

    #2
    Any advice? Or clarification needed? It seems pretty clear what is happening, just not sure how to avoid it. Per the javadocs using ListGridField.setOptionDataSource tells the framework to "Derive a ValueMap by fetching records from another DataSource and extracting the valueField and displayField in the loaded records, to derive one valueMap entry per record loaded from the optionDataSource." And using setOptionOperationId and setOptionCriteria let you customize "the fetch operation to determine data-value to display-value mappings."

    All that works just fine, but when I need to change the criteria how do I tell the framework to refetch the display-value mappings?

    Comment


      #3
      The simplest way to flush caches and cause data re-fetch is to call setFields() again.

      Comment


        #4
        Thanks. I'll try that, but is there any way to flush the display-value cache for the specific field involved rather than for all fields in the grid?

        And shouldn't calling setOptionOperationId or setOptionCriteria do that automatically?

        Comment

        Working...
        X