End Conversation is not working for Natural conversation
thiagu.mr Aug 3, 2013 11:29 AMI want to represent the data in tab panel in the page.
The user can concurrently work on this tab section by open it in separate browser tabs.
I am using natural conversation in this page.
The sample code is below,
The natural conversation is defined as like in my pages.xml
<conversation name="userId" parameter-name="userId" parameter-value="#{homeAction.uid}"/>
And I used this defined conversation in my home.page.xml as like
<page login-required="true" conversation="userId">
<restrict>#{authorization.hasRole()}</restrict>
<begin-conversation join="true" flush-mode="manual"/>
<param name="userId" value="#{homeAction.uid}"/>
<action execute="#{homeAction.init}" on-postback="false"/>
<navigation>
<rule if-outcome="END">
<end-conversation before-redirect="true"/>
<redirect view-id="/home/home.xhtml"/>
</rule>
</navigation>
</page>
my home.xhtml as like
<h:form>
<rich:tabPanel selectedTab="#{homeAction.selectedTab}">
<c:forEach items="#{homeAction.users}" var="item">
<rich:tab name="#{item.userName}" action="#{homeAction.oneTabChange}">
<f:facet name="label">#{item.userName}</f:facet>
<f:param name="userId" value="#{item.id.uid}"/>
<h:panelGrid columns="2">
userName: #{item.userName}
passWord: #{item.passWord}
</h:panelGrid>
</rich:tab>
</c:forEach>
</rich:tabPanel>
</h:form>
And my HomeAction class looks like as blow
@Scope(ScopeType.CONVERSATION)
@Name("homeAction ")
public class HomeAction {
@In(create=true)
private EntityManager entityManager;
private String selectedTab;
private int uid = -1;
private List<UmuserMaster> users;
public void init() {
initUserList();
intiSelectedTab();
}
private void intiSelectedTab() {
String userName = null;
if(uid == -1 && (users != null && !users.isEmpty())){
userName = users.get(0).getUserName();
}else{
userName = (String)entityManager.createQuery("select um.userName from UmuserMaster um " +
"where um.id.uid = :uid")
.setParameter("uid", uid)
.getSingleResult();
}
setSelectedTab(userName);
}
private void initUserList() {
users = entityManager.createQuery("from UmuserMaster um").getResultList();
}
public String oneTabChange(){
return “END”;
}
public String getSelectedTab() {
return selectedTab;
}
public void setSelectedTab(String selectedTab) {
this.selectedTab = selectedTab;
}
public int getUid() {
return uid;
}
public void setUid(int uid) {
this.uid = uid;
}
public List<UmuserMaster> getUsers() {
return users;
}
}
If the user switches from one tab to other, I am ending the current conversation before redirect and the new conversation created before the page redirect.
Now I am facing the problem with conversation end. It is not ending the natural conversation as expected.
So my previous natural conversation is marked as background conversation, and it is destroyed after conversation timeout elapsed (2 min).
Any suggestion how to end the natural conversation in my case?