Uh oh - exclamation points, now I *know* I'm doing something wrong. :)
OK, without going too in depth here's the flow. I have a util class with static
methods looking up the EJB3 stateless SBs:
| Context c = new InitialContext();
| return (EntityLogicRemote) c.lookup("MyProject/EntityLogicBean/remote");
|
There's a controller class that handles the JSF actions. It looks up the remote using
the method above. It then looks up the entity it needs by it's ID, that code in the
bean looks like this:
| MyEntity entity = em.find(MyEntity.class, entityId);
| return entity;
|
Of course that MyEntity is the EJB3 entity bean in question. I am, in fact directly
referencing the returned object within my JSF class (which from your reply must be
problematic). I do realize there are limitations in working with the object, so I've
carefully coded those interactions. Initially I directly accessed that bean's
getTdmAlerts method to get the TdmAlerts collection, which I wrapped in my DataModel
(successfully before I made the relationship lazy). After I made it lazy and started
getting exceptions I changed what I was doing. I currently am trying to pass the entity
instance I get from the above method back to the session bean to refresh() it and get the
TdmAlerts collection (which obviously fails with the same exception).
Now, where I am at 8:35 PM localtime() is that instead of passing the entity back to the
session bean I just pass the site ID and look it up again where (as you'd expect) the
newly returned entity can give me it's TdmAlerts collection without a problem. So
problem solved in one sense, but I really want to do things the Right Way.
I appreciate greatly your help so far, can you give me guidance as to how I should
structure my interactions between JSF and EJB3? When I decided to employ these
technologies on the project (which has worked swimmingly so far) there was absolutely no
documentation that I could find on the web of the "right way" to do things. So
I punted and I got things working so the project could move forward. If I'm designing
badly I'd rather know now and fix things than continue on only to run into significant
problems later.
Thanks again,
Mike
P.S. Before I submit this reply I'm going to guess at a method of doing things the
"right way" and that would be that the JSF project should never interact with
EJB entities at all and only with the EJB session beans. That would explain your VO/TO
post, however I guess I'm still a bit lost at the concept of the proxy that you refer
to. I do use transfer objects to, for example, create an entity from data that a user
fills into a form. Thanks again.
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3978670#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...