You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.
| Online: | 23 Members of 4546 |
| Forum: Seam Users |
17. Sep 2008, 11:06 CET | Link |
Hi,
maybe this is a more or less dumb question: Is it necessary to annotate entity beans with @Name?
@Name tells Seam to instantiate an object of this entity whenever it is referenced. But as I'm thinking about I'm pretty sure that I don't access a plain entity on my pages. Whether there is a h:dataTable which iterates over entity beans or - especially with user
- a special component is set up by another bean and so on.
So I wonder if it's just fine to remove the @Name respectively is there any special reason why an entity should be annotated with @Name?
Thanks Jens
You do not need the @Name-Annotation in a EntityBean, when you do your business stuff in a session bean!
In common, it is better to seperate Model from Controller!
So do your business relevant things only in session beans and use the @Name-Annotation in SessionBeans.
And there is really no specific reason why every entity in the docs and examples got @Names?
Perhaps because CRUD operations in the examples refer to the entity to create by name? If you don't want to bind directly an entity implementation to a view you can use:
@Factory("entityName")and outject an interface or an abstract class (hiding actual implementation to the view), this is the Seam-ish implementation of the Factory pattern.
I knew it was a more or less stupid question. But thanks, I got it again.