I have the following fake support for bean talk:
@Named @ConversationScoped public class TestConversation implements Serializable { private Logger logger = LoggerFactory.getLogger(TestConversation.class); private List<Integer> numbers; @Inject private Conversation conversation; @PostConstruct public void init() { logger.info("Creating TestConversation bean!!!"); numbers = new ArrayList<Integer>(); numbers.add(3); numbers.add(4); numbers.add(5); numbers.add(6); conversation.begin(); } public void commandLinkAction() { logger.info("Invoking commandLinkAction"); } public List<Integer> getNumbers() { return numbers; } }
And the following types of facelets:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"> <h:head> <title>Testing Conversation</title> </h:head> <h:body> <h:form> <h:dataTable value="#{testConversation.numbers}" var="num"> <h:column> <h:outputText value="#{num}"/> </h:column> <h:column> <h:commandLink action="#{testConversation.commandLinkAction}">Trigger form submission</h:commandLink> </h:column> </h:dataTable> </h:form> </h:body> </html>
When I enter the page, I see INFO: Creating TestConversation bean!!! , what is right.
But then I click on h:commandLink and I see:
INFO: Creating a TestConversation bean !!!
INFO: Call commandLinkAction
The bean was created again, which means the conversation was not common. I think this contradicts the following:
Quote from docs :
The long-term conversation context associated with the request that the JSF view displays automatically extends to any person request (JSF form view) that is taken from this displayed page.
If I add this <f:param name="cid" value="#{javax.enterprise.context.conversation.id}"/> then everything will be fine. Do I have a misunderstanding?
PS Without f:param it works fine when I click on commandLink a second time, but not the first time: (.
source share