-
1. Re: Does DataModelSelection work in a Stateless Session Bean
venkateshbr Jan 31, 2007 2:07 AM (in response to twocoasttb)
declare the datamodel under PAGE scope.
@DataModel(scope=ScopeType.PAGE) -
2. OFTOPIC Re: Does DataModelSelection work in a Stateless Sess
mariuszs Jan 31, 2007 2:40 AM (in response to twocoasttb)Btw, you should use:
@Begin public String selectOrganization() { organization = em.merge(selectedOrganization); return "editOrganization"; }
-
3. Re: Does DataModelSelection work in a Stateless Session Bean
twocoasttb Jan 31, 2007 12:47 PM (in response to twocoasttb)Thanks for the responses. Unfortunately, putting the DataModel into PAGE scope doesn't change anything- selectedOrganization is still NULL in selectOrganization().
I'm stuck in phase two (disillusion) of Gavin's "http://blog.hibernate.org/cgi-bin/blosxom.cgi/Gavin%20King/stages-of-adoption.html", and seeking insight. I don't see why this finder bean itself should require any state. Am I wrong? It certainly shouldn't have to around in SESSION scope.
I should have mentioned before, I'm using Seam 1.1.1GA and JBoss 4.0.5
Side Note:
Don't ever set var="org" in a dataTable. Doing so causes Seam to go nuts searching contexts and it eventually throws an exception because can't find a property called 'jboss' in the entity bean. Should I report this as a bug? I'd be happy to provide a test case. Using var="o" changes the behavior completely.[/url] -
4. Re: Does DataModelSelection work in a Stateless Session Bean
pmuir Jan 31, 2007 1:07 PM (in response to twocoasttb)"twocoasttb" wrote:
I don't see why this finder bean itself should require any state. Am I wrong? It certainly shouldn't have to around in SESSION scope.
It needs some state - a stateless bean looses state between each invocation - it is invoked update data model (i think?) to set the datamodel selection, and then in INVOKE_APPLICATION to call the action - the state is lost between these. Further, you need to hold the state of the datamodel between the two requests - this is due to how JSF works (the restore view phase). The PAGE or CONVERSATION scope is ideal for this
[qupte]Don't ever set var="org" in a dataTable. Doing so causes Seam to go nuts searching contexts and it eventually throws an exception because can't find a property called 'jboss' in the entity bean. Should I report this as a bug? I'd be happy to provide a test case. Using var="o" changes the behavior completely. -
5. Re: Does DataModelSelection work in a Stateless Session Bean
pmuir Jan 31, 2007 1:09 PM (in response to twocoasttb)Oops.
Don't ever set var="org" in a dataTable. Doing so causes Seam to go nuts searching contexts and it eventually throws an exception because can't find a property called 'jboss' in the entity bean. Should I report this as a bug? I'd be happy to provide a test case. Using var="o" changes the behavior completely.
Yes, this is known bug but isn't in JIRA afaics, so please put it in :) -
6. Re: Does DataModelSelection work in a Stateless Session Bean
twocoasttb Jan 31, 2007 8:30 PM (in response to twocoasttb)Ok. I understand why PAGE scope is appropriate, and recognize why it's the right scope for my finder bean. A conversation isn't required until an item in the list is selected for editing. A SFSB can't have PAGE scope (right?), so I assume the DataModel should. So my finder bean now looks like this:
@SuppressWarnings("serial") @Stateful @Name("organizationFinder") public class OrganizationFinderBean implements OrganizationFinder, Serializable { @PersistenceContext private EntityManager em; @In (required=false) @Out (required=false) private Organization organization; @DataModel(scope=ScopeType.PAGE) private List<Organization> organizations; @DataModelSelection Organization selectedOrganization; @Logger private Log log; @SuppressWarnings("unchecked") @Factory public void getOrganizations() { organizations = em.createQuery("select o from Organization o order by o.name") .getResultList(); } @Begin public String newOrganization() { organization = new Organization(); return "newOrganization"; } @Begin public String selectOrganization() { organization = em.merge(selectedOrganization); return "editOrganization"; } @Remove @Destroy public void destroy() {} }
and my dataTable looks like this:<h:dataTable id="organizations" value="#{organizations}" var="o"> <h:column> <f:facet name="header">Prefix</f:facet> #{o.prefix} </h:column> <h:column> <f:facet name="header">Name</f:facet> #{o.name} </h:column> <h:column> <f:facet name="header">Legal Name</f:facet> #{o.legalName} </h:column> <h:column> <f:facet name="header">Action</f:facet> <s:link id="editOrganization" value="Edit" action="#{organizationFinder.selectOrganization}"/> </h:column> </h:dataTable>
When I select an item in the list I get the following exception:
javax.ejb.EJBException: java.lang.IllegalArgumentException: attempt to create merge event with null entity
Based on a post I just saw, I think I'll try injecting the DataModelSelection directly into my edit bean. It seems though, based on prior comments and reading the docs, that the above should work. I assume I'm missing something stupid... Any ideas will be much appreciated.