-
1. Re: Accessing @DataModel in POJO
lvdberg Oct 11, 2010 6:54 AM (in response to notify)Hi,
I assume the EJB is a stateful bean, which by default has a conversation scope, while a normal bean has a event scope. I cant see the rest of your code, but it is most ceratinly the cause of your problem.
Leo
-
2. Re: Accessing @DataModel in POJO
notify Oct 11, 2010 6:58 AM (in response to notify)Leo,
Yes it's a Stateful EJB, but the scope is set to session.
@Stateful
@Name(postcardBean
)
@Interceptors(SeamInterceptor.class)
@JndiName(ejb/PostcardRemote
)
@Scope(ScopeType.SESSION)
public class PostcardBean implements PostcardRemote, NOTiFYPiNPOiNTConstants, NOTiFYPiNPOiNTSQL { -
3. Re: Accessing @DataModel in POJO
lvdberg Oct 11, 2010 7:29 AM (in response to notify)Hi,
this explains why it
always
works. The bean is created when you start the session and stays in memory until the user signs-off. How is the list of entities created ? and have you done the same for the POJO )session scope)?Leo
P.S: please send in additional code because I am not a medium.
-
4. Re: Accessing @DataModel in POJO
notify Oct 11, 2010 7:50 AM (in response to notify)
How is the list of entities created ? and have you done the same for the POJO )session scope)?The Enities are created here;
@SuppressWarnings({ "unchecked" }) @Factory("postcardsList") public final List <Postcards> getPostCardsByDomain() { Query query = entityManager.createQuery(GET_POSTCARDS_BY_DOMAIN); query.setParameter(ONE, this.getDomain(credentials.getUsername())); this.postcardsList = query.getResultList(); log.info(">>>>> getPostCardsByDomain postcardsList.size = " + postcardsList.size()); return this.postcardsList; }
and stored in the list;
@DataModel @Out (required = false) private List <Postcards> postcardsList;
I am trying to inject the postcardsList (the DataModel) into the POJO.
The POJO is referenced in the faces-config.xml with a scope of session;
<managed-bean> <managed-bean-name>fileUploadBean</managed-bean-name> <managed-bean-class>com.notifypinpoint.pojos.FileUploadBean</managed-bean-class> <managed-bean-scope>session</managed-bean-scope> </managed-bean>
-
5. Re: Accessing @DataModel in POJO
lvdberg Oct 11, 2010 7:56 AM (in response to notify)Ok,
that makes sense now. You're not using a Seam managed bean. Try making the POJO a seam.bean by adding the name- and scope annotations and try again.
Leo
-
6. Re: Accessing @DataModel in POJO
notify Oct 11, 2010 8:35 AM (in response to notify)
Try making the POJO a seam.bean by adding the name- and scope annotations and try again.I already had;
@Name("fileUploadBean") @Scope(ScopeType.SESSION) public class FileUploadBean implements NOTiFYPiNPOiNTConstants {
-
7. Re: Accessing @DataModel in POJO
lvdberg Oct 11, 2010 11:46 AM (in response to notify)Hi,
If you have the POJO as a Seam bean, why are you defining it again in faces-config.xml ?
Leo
-
8. Re: Accessing @DataModel in POJO
notify Oct 11, 2010 12:04 PM (in response to notify)
If you have the POJO as a Seam bean, why are you defining it again in faces-config.xml ?Leo,
I realised whilst I was out I was mixing a POJO with a Seam Bean. Thanks for highlighting it to me.
My EAR won't deploy now as it says;
ERROR [[/]] Exception sending context initialized event to listener instance of class org.jboss.seam.servlet.SeamListener java.lang.RuntimeException: Could not create Component: imagesBean
Do I have registers any Seam Componets to use a Seam Bean?
Thanks for your help.
-
9. Re: Accessing @DataModel in POJO
lvdberg Oct 11, 2010 1:58 PM (in response to notify)Hi,
you must follow the basic rules for Seam , meaning add configurations to web.xml and - if you use facelets - the view handler setting in faces config and also the seam.properties file inside META-INF (or other jars). The seam documentation contains a clear explanation how to configure a basic seam environment and seam-gen can help you kick-start your new application.
Leo
-
10. Re: Accessing @DataModel in POJO
notify Oct 11, 2010 3:12 PM (in response to notify)
you must follow the basic rules for Seam , meaning add configurations to web.xml and - if you use facelets - the view handler setting in faces config and also the seam.properties file inside META-INF (or other jars). The seam documentation contains a clear explanation how to configure a basic seam environment and seam-gen can help you kick-start your new application.Cleaned up my JBoss directories etc and all is well and the Entity is being injected.
Thanks for your patience and suggestions.