SmartClient Version: v13.0p_2023-04-25/PowerEdition Deployment (built 2023-04-25)
I have seen that many forms of this question have been asked in the past:
https://forums.smartclient.com/forum/smart-gwt-technical-q-a/255013-formitem-display-value-cache-problem#post255013
https://forums.smartclient.com/forum/technical-q-a/261984-12-0p-listgrid-enforcing-request-on-fetchdata-without-using-invalidatecache#post261984
amongst many.
I have a DynamicForm with 5 select Items. I have ONE of these 5 that is used to generate the pick list criteria of say the first two select Items.
I have a setPickListFilterCriteriaFunction on these first two select items.
There is a SelectItem called Block_Name. Changes in the selection of Block Name will cause new Criteria to be generated for the two other select items, as shown.
I have added a FormItem("Block_Name").addChangedHandler in the Dynamic form, and inside of that ChangedHandler I have:
1. FormItem ( 1 or 2) .invalidateDisplayCache() - no effect
2. FormItem (1 or 2) . getOptionDataSource.invalidateCache(true) or getOptionDataSource.invalidateCache() and neither of these cause a new fetchData.
What DOES work, is in the Canvas that instantiates this whole DynamicForm, with the multiple SelectItems, to call
myDynamicForm.invalidateCache()
But this is hitting the whole form with a sledge hammer.
I would like to have changes in the Block_Name selector cause the caches of selectors 1 and 2 to be cleared so as to force SQL fetches. But what happens after the first selections of 1 and 2 is that selecting the pick list icon the Select list is blank.
Select items 1 and 2 do NOT return Block_Name as a field of their display fields, just other values.
Nothing I have attempted, except the full invalidate of the entire DynamicForm, has caused these items 1 and 2 to fetch again with the changed criteria.
What am I missing?
I have seen that many forms of this question have been asked in the past:
https://forums.smartclient.com/forum/smart-gwt-technical-q-a/255013-formitem-display-value-cache-problem#post255013
https://forums.smartclient.com/forum/technical-q-a/261984-12-0p-listgrid-enforcing-request-on-fetchdata-without-using-invalidatecache#post261984
amongst many.
I have a DynamicForm with 5 select Items. I have ONE of these 5 that is used to generate the pick list criteria of say the first two select Items.
I have a setPickListFilterCriteriaFunction on these first two select items.
Code:
selectItem.setPickListFilterCriteriaFunction(new FormItemCriteriaFunction() { @Override public Criteria getCriteria(FormItemFunctionContext itemContext) { AdvancedCriteria basicCrit = getFormAdvancedCriteria() ; if ( !"Block_Name".equalsIgnoreCase(itemContext.getFormItem().getName() )) { if ( !controls.isEmpty() && Boolean.TRUE.equals(qualifyByBlock.getValueAsBoolean()) ) { FormItem block = controls.stream().filter( f-> "Block_Name".equals(f.getName()) ).findAny().orElse(null); if ( block != null) { ArrayList<String> blockNames = (ArrayList<String>)block.getValue(); if ( blockNames != null && !blockNames.isEmpty() ) { Criterion blockCrit = new Criterion("Block_Name", OperatorId.IN_SET, blockNames.toArray(new String[blockNames.size()])); basicCrit = BCUtils.combineAdvancedCriteria(basicCrit,blockCrit) ; } } } else { return basicCrit; } return BCUtils.combineAdvancedCriteria(basicCrit, getSTAExtraCriteria()); } }); // controls is an ArrayList of FormItems in the DynamicForm, created elsewhere.
I have added a FormItem("Block_Name").addChangedHandler in the Dynamic form, and inside of that ChangedHandler I have:
1. FormItem ( 1 or 2) .invalidateDisplayCache() - no effect
2. FormItem (1 or 2) . getOptionDataSource.invalidateCache(true) or getOptionDataSource.invalidateCache() and neither of these cause a new fetchData.
What DOES work, is in the Canvas that instantiates this whole DynamicForm, with the multiple SelectItems, to call
myDynamicForm.invalidateCache()
But this is hitting the whole form with a sledge hammer.
I would like to have changes in the Block_Name selector cause the caches of selectors 1 and 2 to be cleared so as to force SQL fetches. But what happens after the first selections of 1 and 2 is that selecting the pick list icon the Select list is blank.
Select items 1 and 2 do NOT return Block_Name as a field of their display fields, just other values.
Nothing I have attempted, except the full invalidate of the entire DynamicForm, has caused these items 1 and 2 to fetch again with the changed criteria.
What am I missing?
Comment