-
1. Re: Can @DataModel be replaced with EntityQuery?
admin.admin.email.tld Aug 6, 2008 8:38 PM (in response to wilczarz.wilczarz.gmail.com)that's interesting. can u post some code?
I've never heard of not being able to use conversation scope for a Seam component...
-
2. Re: Can @DataModel be replaced with EntityQuery?
wilczarz.wilczarz.gmail.com Aug 7, 2008 9:52 AM (in response to wilczarz.wilczarz.gmail.com)Sure. This is my component:
@Name( "clientList" ) @Scope( CONVERSATION ) public class ClientList extends EntityQuery<Client> { @Override public String getEjbql() { return "from Client"; } }
the page that uses it (rendered outside any conversation):
<rich:dataTable id="clientList" var="loopClient" value="#{clientList.dataModel}" > <rich:column> <h:form> <h:commandLink value="#{loopClient.name}" action="#{sampleAction.showClient}" /> </h:form> </rich:column> </rich:dataTable>
and my session bean:
@Stateful @Name( "sampleAction" ) @Scope( CONVERSATION ) public class SampleAction implements SampleLocal { ... @In(create = true) @Out @DataModelSelection private Client client; ... @Begin public String showClient() { ... }
Like I said, for CONVERSATION scope in EntityQuery the table renders empty. Now, everyting works fine with
@DataModel private List<Client> clients; @Factory( "clients" ) public void findUsers() { clients = entityManager.createQuery("from Client").getResultList(); }
and
<rich:dataTable id="clientList" var="loopClient" value="#{clients}" > <rich:column> <h:form> <h:commandLink value="#{loopClient.name}" action="#{sampleAction.showClient}" /> </h:form> </rich:column> </rich:dataTable>
because
If no scope is explicitly specified for @DataModel, the scope of the component with the @DataModel attribute is used
. That works for the SessionBean, but not for EntityQuery. -
3. Re: Can @DataModel be replaced with EntityQuery?
baz Aug 7, 2008 10:12 AM (in response to wilczarz.wilczarz.gmail.com)
the page that uses it (rendered outside any conversation):<rich:dataTable id="clientList" var="loopClient" value="#{clientList.dataModel}" >
try to use resultList instead of datamodel. Here is a link to the seam issue tracker.
JBSEAM-2684BTW: Can anybody explain why i should use dataModel? I have ever used resultList
-
4. Re: Can @DataModel be replaced with EntityQuery?
wilczarz.wilczarz.gmail.com Aug 7, 2008 10:26 AM (in response to wilczarz.wilczarz.gmail.com)I've tried that but resultList seems incompatible with @DataModelSelection. Nothing gets injected.
-
5. Re: Can @DataModel be replaced with EntityQuery?
wilczarz.wilczarz.gmail.com Aug 7, 2008 5:22 PM (in response to wilczarz.wilczarz.gmail.com)Ok, I found a workaround for this problem. The DataModel needs to be created manually in EntityQuery:
@Name( "clientList" ) @Scope( CONVERSATION ) public class ClientList extends EntityQuery<Client> { @Factory( value = "clients", scope = ScopeType.CONVERSATION ) public ListDataModel findClients() { List<Client> clients = getResultList(); return new ListDataModel( clients ); } @Override public String getEjbql() { return "from Client"; } }
Generally I think it's a good idea to separate any entity's DataModel population from the SessionBean the selection goes to. I'm just not sure if this is the best way to do it.
-
6. Re: Can @DataModel be replaced with EntityQuery?
pmuir Aug 8, 2008 2:50 PM (in response to wilczarz.wilczarz.gmail.com)Most likely the ManagedEntityIdentityInterceptor rearing its ugly head - this is turned off by default in trunk, and we are working on a replacement solution for clustering failover.