Hello JW, AK and everybody
Scenario:
CFAzienda entity
CFAzienda have some attributes and some relationships actually we need to discuss abuout relationships
i have two entities
CFSettore CFServizio
the relationships map is
CFAzienda <<----> CFSettore ( relationship name is "settore" ) CFAzienda <<---->> CFServizio ( relationship name is "serviziOfferti" )
Now I have to display the CFAzienda in a DisplayGroup and i have two popup menus for filtering the group
one popup menu have a list of CFSettore and the other a list of CFServizio
as usual I was using this method:
. . EODatabaseDataSource ds = ((Session)session()).getAziendeController().dataSource(); displayGroup.setDataSource(ds); . .
public void setQualifiers() { NSMutableDictionary<String, EOGenericRecord> dict = new NSMutableDictionary<String, EOGenericRecord>(); dict.takeValueForKey(true,"isEnabled");
if( selectedSettore!=null ) { dict.takeValueForKey(selectedSettore, "settore"); }
if( selectedServizio!=null ) { dict.takeValueForKey(selectedServizio, "serviziOfferti"); }
EOQualifier q = EOQualifier.qualifierToMatchAllValues(dict.immutableClone()); displayGroup.setQualifier(q); displayGroup.updateDisplayedObjects(); }
And this works file if the display group is an ERXBatchingDisplayGroup
but today for some reasons i discovered that the but ERXBatchingDisplayGroup ( due to the nature of batching ) have the filteredObject() returning a ERXBatchingDisplayGroup.fakeArray instead on an NSArray of objects, so I decided to use the ERXDisplayGroup instead
now the problem:
the CFservizio qualifier doesn't work anymore, or better, no data is displayed at all, practically this
if( selectedServizio!=null ) { dict.takeValueForKey(selectedServizio, "serviziOfferti"); }
is not working, remember that the relationship "serviziOfferti" is a to many.
After some testing and looking at both ERXDisplayGroup and the ERXBatchingDisplayGroup source code, I realized that the problem is how ERXDisplayGroup fetch data, then I decided to do filtering directly in the DataSource...
public void setQualifiers() { NSMutableDictionary<String, EOGenericRecord> dict = new NSMutableDictionary<String, EOGenericRecord>(); dict.takeValueForKey(true,"isEnabled");
if( selectedSettore!=null ) { dict.takeValueForKey(selectedSettore, "settore"); }
if( selectedServizio!=null ) { dict.takeValueForKey(selectedServizio, "serviziOfferti"); }
EOQualifier q = EOQualifier.qualifierToMatchAllValues(dict.immutableClone()); ds.setAuxiliaryQualifier(q); //ds IS THE DATA SOURCE
displayGroup = new ERXDisplayGroup<CFAzienda>(); displayGroup.setSortOrderings(nameOrdering.immutableClone()); displayGroup.setDataSource(ds); displayGroup.fetch(); }
This is working, but requires to destroy and refetch the displaygroup everytime. That's all
Any comment ?
Regards Amedeo
On 13/gen/2011, at 18.04, Johann Werner wrote: Hi Amedeo, perhaps you could post the code you use to create the display group and set its qualifiers, so we can have a look at? jw Am 13.01.2011 um 16:53 schrieb Amedeo Mantica: I have an ERXBatchingDisplayGroup that is working fine, but just today calling the method filteredObject I discovered that the ERXBatchingDisplayGroup will not return a real NSArray of objects but instead a special ERXBatchingDisplayGroup.fakeArray that is not suitable for me.
So due to the fact that the datasource is small i decided to give up batching and basically use the simpler ERXDisplayGroup, simply replacing "ERXBatchingDisplayGroup" with "ERXDisplayGroup", but now the displaygroup won't set qualifiers anymore.
Any reason ?
Thanks
Regards
Amedeo
|