Nested conversation
vincent.crepin Sep 25, 2008 5:33 AMHello Seam users.
I know that this kind of problem has been submitted many times in many different flavors but I can't determine the cause of my problem.
Here is a description of it.
I Have an application which consists mainly of 2 pages. The first is a list of items and the second is an editor page for an item in the list.
When I enter the first page, I start a Conversation (@Begin) on a stateful bean with Conversation scope. I need this conversation because my list must keep track of different states as sort order, sort field, page selected etc.
When I click on an item to edit it, I switch to the second page starting a nested conversation. I can then take action on the item and return to the list that I find in the state I left it. My problem starts here. The list is correctly rendered but when I do an action on it, I get an exception (NullPointerException) on the first property of the backing bean that I access.
I put the conversationList dataTable on my pages to track the conversations and everything seems fine. On the first page, I have 1 conversation. On the second, I have 2 with the second as current and it is nested. When I come back to my list page, I have only one conversation left and it is exactly the same as when I started (same ID, accessedDate refreshed).
So, here are the relevant portions of code:
The method that starts the conversation on the list backing bean
@Begin @Override @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public String enterList() { this.currentKilometerEntryMonth = null; this.com_servier_hr_session_uievents_kilometerEntryMonths = null; queryObjects(); this.carPanelRendered = false; return "kilometerEntryMonthList"; }
kilometerEntryMonthList is the logical name of the list page as defined in
pages :
<page view-id="/kilometerEntry/kilometerEntryMonthList.xhtml" login-required="true"> <description>The month list page of the application</description> <navigation> <rule if-outcome="carList"> <redirect view-id="/kilometerEntry/#{com_servier_hr_session_uievents_carListAction.enterList()}.xhtml"> </redirect> </rule> </navigation> </page>
The link to the second page :
<a4j:commandLink id="monthListYearMonthColumnLink" action="#{com_servier_hr_session_uievents_kilometersEdit.enterEdit(kilometerEntryMonthDTO)}"> <h:outputText value="#{kilometerEntryMonthDTO.yearMonth}" id="monthListYearMonthColumnOutputText" /> <f:param name="conversationPropagation" value="join" /> <s:conversationPropagation type="join" /> </a4j:commandLink>
The method enterEdit on the backing bean of the second page :
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) @Begin(nested = true) public String enterEdit(KilometerEntryMonthDTO kilometerEntryMonthDTO) { this.ownerServierUser = null; this.setPreviousKilometerEntry(null); this.nextKilometerEntry = null; this.setCurrentKilometerEntry(null); this.currentKilometerEntryMonth = null; this.com_servier_hr_session_uievents_car = null; createNeededServices(); ---
The link on the second page to return to the first :
<rich:menuItem submitMode="ajax" id="goBackToListMenuItem" value="#{messages['KilometerEntry.cmdBack.tooltip']}" action="#{com_servier_hr_session_uievents_kilometersEdit.returnToMonthList()}" eventsQueue="treeQueue" bypassUpdates="true" immediate="true" <f:facet name="icon"> <h:graphicImage value="/img/actions/back.gif" id="goBackToListImage" /> </f:facet> </rich:menuItem>
The method on the backing bean of the second page that ends the nested conversation :
@End() @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public String returnToMonthList() { return "kilometerEntryMonthList"; }
The entry for that second page in pages.xml :
<page view-id="/kilometerEntry/kilometerEntryList.xhtml" login-required="false"> <description>The edition of the monthly entries</description> <navigation> <rule if-outcome="kilometerEntryMonthList"> <redirect view-id="/kilometerEntry/#{com_servier_hr_session_uievents_KilometerEntryMonthSearch.returnToList()}.xhtml"> </redirect> </rule> </navigation> </page>
And finally, the method on the backing bean of the list page that the previous navigation rule refers to :
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public String returnToList(){ queryObjects(); if(this.sortField!=null){ this.sortAscending = !this.sortAscending; this.sortDataList(this.sortField); } return "kilometerEntryMonthList"; }
Voila, if someone sees something that I don't, it would be highly appreciated.
Vincent.