Hello, I have a simple ComboBox presenting a list of entities, which is backed by JPAContainer.
When I use this ComboBox “normally” by adding it to a layout, the entity sorting is working properly:
MunicipalitySelector homeMunicipality = new MunicipalitySelector("Municipality");
addComponent(homeMunicipality);
Homever, this is not the case when building the form (for a Person entity) automatically with FieldFactory:
setSingleSelectType(Municipality.class, MunicipalitySelector.class);
The entities are always sorted by their id’s and the sorting property is ignored.
I am defining the sorting this way in the ComboBox:
JPAContainer<Municipality> container = JPAContainerFactory.make(Municipality.class, Application.PERSISTENCE_UNIT);
container.setApplyFiltersImmediately(false);
container.sort(new String[] { Municipality.NAME }, new boolean[]
{ true });
setConverter(new SingleSelectConverter<Municipality>(this));
setContainerDataSource(container);
for (Object id : container.getItemIds()) {
Municipality m = container.getItem(id).getEntity();
setItemCaption(id, m.getName());
}
The Municipality entity is linked to a Person entity via @ManyToOne(fetch = FetchType.LAZY), using EclipseLink.
Can this have something to do with FieldFactory’s way of instantiating a .newInstance() of the selector? I have debugged the selector code and made sure container.sort() is executed, but somehow it’s still suspicious.
Or can it be a bug in FieldFactory somehow overriding the container sorting?
Thanks for your time!
Greetings,