-
1. Re: Restriction with using DataModelSelection and sorted resultset?
gonorrhea Jun 12, 2009 12:43 AM (in response to gonorrhea)The following seems to be using
random
entities as well:<a4j:commandLink value="Edit" ajaxSingle="true" action="#{recoveredEquipmentManagement.edit(listVal)}" oncomplete="rerenderRecoveredEquipmentManagementModal();"/>
anybody have any workaround for this (other than removing the sorting)?
-
2. Re: Restriction with using DataModelSelection and sorted resultset?
kapitanpetko Jun 12, 2009 5:35 AM (in response to gonorrhea)I've found @DataModelSelection to be unreliable (at least in 2.0, haven't tried it lately), so you are probably
better off using JBOSS EL. But maybe that was IE's fault, not Seam's. I ditched @DataModelSelection early on
and haven't looked back.But your problem is, probably, that your @DataModel is not properly refreshed after you sort
(or @DataModelSelection is, for some reason, using the old model).Try something like this:
Contexts.getConversationContext().remove("recoveredEquipmentManagmentList"); recoveredEquipmentManagementList = criteria.list();
-
3. Re: Restriction with using DataModelSelection and sorted resultset?
gonorrhea Jun 12, 2009 6:00 AM (in response to gonorrhea)Thanks for the response!
Here is a related thread: http://seamframework.org/Community/DataModelSelectionAndSortByNotFunctional
however, in that thread, the developer was sorting by header clicks, not by 'order by' clause in the generated native SQL.
Right now I seem to have it working fine by passing the entity in the method call to edit().
Somewhere (book, wiki, forum??) I remember reading that sorting of <rich:dataTable> and @DataModelSelection injection don't work properly, but can't recall exactly the root cause and/or workaround or fix for that. And I do remember experiencing the same problem in the cited thread (clickable header sort messes up the injected entity).
But your problem is, probably, that your @DataModel is not properly refreshed after you sort (or @DataModelSelection is, for some reason, using the old model).This is most likely not the case. The @DataModel outjects to the scope of the Seam component (unless otherwise specified as an attribute value), in this case conversation context, and this happens after each successful business method execution. You would hope that @DataModel and @DataModelSelection are synchronized. It definitely seems buggy to me...
-
4. Re: Restriction with using DataModelSelection and sorted resultset?
kapitanpetko Jun 12, 2009 6:09 AM (in response to gonorrhea)
Arbi Sookazian wrote on Jun 12, 2009 06:00:
This is most likely not the case. The @DataModel outjects to the scope of the Seam component (unless otherwise specified as an attribute value), in this case conversation context, and this happens after each successful business method execution. You would hope that @DataModel and @DataModelSelection are synchronized. It definitely seems buggy to me...Well, I might be wrong about your problem, but @DataModel is indeed special.
Cf. Component.outjectDataModel:boolean dirty = existingDataModel == null || wrapper.isDirty(dataModelAnn, existingDataModel, list); boolean reoutject = existingDataModel!=null && scope==PAGE; if (dirty) { if ( list!=null ) { context.set( name, wrapper.wrap(dataModelAnn, list) ); } else { context.remove(name); } } else if (reoutject) { context.set(name, existingDataModel); }
wrapper.isDirty (in DataModelBinder) calls equals on the list you are trying to outject and the current one to
determine if it has changed. That is meant to be an optimization, but is quite counter-intuitive,
I think. Premature optimization and all that...Anyway, if you sort the list, the order changes, so isDirty should return true and the new
Datamodel should be properly outjected. Which proves that I was wrong :)