开发者

How do I use CODI Conversation? Specifically, how to end it?

开发者 https://www.devze.com 2023-04-06 11:46 出处:网络
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 f

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.s开发者_C百科cope.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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号