This content has been marked as final.
Show 2 replies
-
1. Re: Synchronizing to DataModels
bfo81 Aug 10, 2006 4:46 AM (in response to urswag)I'm not sure what you mean exactly. Please give me an example :).
-
2. Re: Synchronizing to DataModels
urswag Aug 10, 2006 9:16 AM (in response to urswag)I have two stateless session beans assortmentManager and categoryManager. Category is a detail bean of Assortment (1:N relation).
In the inner data table the assortmentCategories list must always built up because the reference assortmemt always changes.
Remember the JSF code
<h:dataTable var="assort" value="#{assortments}">
<h:column>
<h:outputLink value="">
<h:outputText value="#{assort.description}" />
</h:outputLink>
<h:dataTable var="category" value="#{assortmentCategories}">
<h:column>
<h:outputLink value="">
<h:outputText value="#{category.description}" />
</h:outputLink>
</h:column>
</h:dataTable>
</h:column>
</h:dataTable>
The code of the both session beans. I need a synchronize mechanism for the list assortmentCategories of the inner data table.
package ...;
import ....;
@Stateless
@Scope(SESSION)
@Name("assortmentManager")
@Interceptors(SeamInterceptor.class)
public class AssortmentManagerBean implements Serializable, AssortmentManager {
@DataModel
private List<Assortment> assortments;
@PersistenceContext
private EntityManager em;
@Factory("assortments")
public void findAssortments() {
assortments = em.createQuery("from Assortment a order by a.description")
.getResultList();
}
@Remove
@Destroy
public void destroy() {
}
}
The other bean
package ....;
import ...;
@Stateless
@Scope(SESSION)
@Name("categoryManager")
@Interceptors(SeamInterceptor.class)
public class CategoryManagerBean implements Serializable,
CategoryManager {
@DataModel
private List<Category> assortmentCategories;
@PersistenceContext
private EntityManager em;
@Factory("assortmentCategories")
public void findCategories() {
Query query = em
.createQuery("from Category c where c.assortment = :assortment");
query.setParameter("assortment", assortment);
assortmentCategories = query.getResultList();
}
@Remove
@Destroy
public void destroy() {
}