0

Based on advice posted here and here, I looked into and installed MyFaces CODI with my application. My biggest concern was overcoming the shortcomings of Weld's implementation of @ConversationScoped feature. After some hiccups I got it running on my GlassFish 3.1 development platform, and I converted all my beans to use

import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.ConversationScoped;

In the end it seems like I am now not much further along than I was before. I do not have to call the conversation.begin() method anymore, which is good, but the beans hang around after the browser has left the page and come back.

What I was hoping for was the functionality of JSF 2.0 @ViewScoped that works with CDI. Once the user leaves the page, the backing bean should be discarded and re-created again if the user comes back. Is there a way to do this with CODI?

Incidentally, the documentation says it will pick up the @ViewScoped annotations and process them properly. I tried this and got and Weld wouldn't deploy it.

P.S. I am using myfaces-extcdi-dist-jsf20 version 0.9.5. I tried installing the core and JSF 2 optional module akibe but it would not deploy on my GlassFish/Weld platform. Any advice here much appreciated.

UPDATE 1: I ended up trying the ViewAccessScope annotation supported by CODI, and that seems to do what I wanted.

Follow-up question. The latest bundle that the maven repository that Apache maintains is 0.9.5 -- Can someone post the pom.xml segment that fetches the latest version?

Community
  • 1
  • 1
AlanObject
  • 9,613
  • 19
  • 86
  • 142
  • Call conversation.close() before returning - ensure that you imported the correct annotation org.apache... and not javax... - see https://cwiki.apache.org/confluence/display/EXTCDI/JSF+Usage#JSFUsage-TerminatingConversations or use the ViewAccessScope instead. We are using: http://repo2.maven.org/maven2/org/apache/myfaces/extensions/cdi/bundles/myfaces-extcdi-bundle-jsf20/1.0.1/myfaces-extcdi-bundle-jsf20-1.0.1.jar in Glassfish 3.1.1 without problems. myfaces-extcdi-bundle-jsf20-1.0.1.jar is the only jar you need. – Dar Whi Sep 21 '11 at 00:47
  • @DarWhi if you post your answer as an answer I will green-check it for you. Please see the update to my question. – AlanObject Sep 21 '11 at 19:59
  • The Maven config for the all in one package is documented at https://cwiki.apache.org/confluence/display/EXTCDI/Module+Overview#ModuleOverview-CODIprepackagedbundles – Dar Whi Sep 21 '11 at 22:28

1 Answers1

2

Call conversation.close() before returning - ensure that you imported the correct annotation org.apache... and not javax... - see Wiki or use the ViewAccessScope instead. We are using: bundle in Glassfish 3.1.1 without problems. myfaces-extcdi-bundle-jsf20-1.0.1.jar is the only jar you need. Please also note that there is no "it". With CODI you have fine-grained groupable conversations instead of the monolithic and inflexible stuff you get with standard CDI conversations.

The set-up for the latest version with a Maven build is also in the Wiki.

Dar Whi
  • 822
  • 5
  • 14