4 Replies Latest reply on Jul 10, 2007 6:57 PM by sunil.su

    long running conversation problem

      Hi,

      I am using Seam 1.2.1, Ajax4jsf and Jboss AS 4.0.5.

      My web page has a data table with one of the columns being an s:link. The s:link action refers to a method on the backing SFSB. I have set the propagation attribute in s:link to true. The same page is rendered when the method returns.

      The problem I am having is that a new conversation is started when I click on the link and the page is rerendered instead of joining the existing conversation. This creates a new instance of the backing SFSB.

      I also dont see the "cid=x&clr=true" in the url similar to what you see in the booking example.

      I would appreciate any help on this issue.

      Thanks

        • 1. Re: long running conversation problem

          sorry, propagation is set to "join"

          • 2. Re: long running conversation problem
            pmuir

            Post code!

            • 3. Re: long running conversation problem

              Here is the page

              <!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"
               xmlns:s="http://jboss.com/products/seam/taglib"
               xmlns:a4j="https://ajax4jsf.dev.java.net/ajax">
              <head>
               <link href="style.css" rel="stylesheet" type="text/css"/>
              </head>
              <body>
              
              <h2>Create Org</h2>
              
              <f:facet name="beforeInvalidField">
               <h:graphicImage styleClass="errorImg" value="error.png"/>
              </f:facet>
              <f:facet name="afterInvalidField">
               <s:message styleClass="errorMsg" />
              </f:facet>
              <f:facet name="aroundInvalidField">
               <s:div styleClass="error"/>
              </f:facet>
              <h:form>
               <h1>Org</h1>
               <fieldset>
               <h:commandButton value="Org" action="#{orgmanager.start}" styleClass="button" />
               </fieldset>
              </h:form>
              <h:form>
              <s:validateAll>
              <table>
               <tr>
               <td>Org Name:</td>
               <td>
               <s:decorate>
               <h:inputText value="#{orgEntry.name}" size="32">
               </h:inputText>
               </s:decorate>
               </td>
               </tr>
              
               <tr>
               <td>Org Code:</td>
               <td>
               <a4j:outputPanel id="orgcode">
               <f:subview rendered="#{!empty(codeErrorMsg)}">
               <f:verbatim><div class="error"></f:verbatim>
               <h:graphicImage styleClass="errorImg" value="error.png"/>
               </f:subview>
              
               <h:inputText value="#{orgmanager.orgCode}" size="32">
               <a4j:support event="onblur" reRender="orgcode"/>
               </h:inputText>
               <f:subview rendered="#{!empty(codeErrorMsg)}">
               <h:outputText styleClass="errorMsg"
               value="#{codeErrorMsg}"/>
               <f:verbatim></div></f:verbatim>
               </f:subview>
               </a4j:outputPanel>
               </td>
               </tr>
              
               <tr>
               <td>Org Description:</td>
               <td>
               <s:decorate>
               <h:inputText value="#{orgEntry.description}" size="32">
               </h:inputText>
               </s:decorate>
               </td>
               </tr>
              
               <tr>
               <td>Org Level:</td>
               <td>
               <a4j:outputPanel id="orglevel">
               <s:decorate>
               <h:panelGroup>
               <h:selectOneMenu value = "#{orgLevelStr}">
               <f:selectItems value="#{orgLevels}" />
               <a4j:support event="onchange" action="#{orgmanager.getParentOrgCodes}"
               ajaxSingle="true" reRender="orgparent" />
               </h:selectOneMenu>
               </h:panelGroup>
               </s:decorate>
               </a4j:outputPanel>
               </td>
               </tr>
              
               <tr>
               <td>Org Parent:</td>
               <td>
               <a4j:outputPanel id="orgparent">
               <s:decorate>
               <h:panelGroup>
               <h:selectOneMenu value = "#{orgmanager.parentOrgCode}">
               <s:selectItems value="#{parentOrgCodes}" var="parentOrgCode" label="#{parentOrgCode}" />
               </h:selectOneMenu>
               </h:panelGroup>
               </s:decorate>
               </a4j:outputPanel>
               </td>
               </tr>
              </table>
              </s:validateAll>
              
              <h:commandButton type="submit"
               value="Create Org"
               action="#{orgmanager.createOrg}"/>
              </h:form>
              
              <p>Orgs:</p>
              
              <h:form>
              <h:dataTable id="orgList" value="#{orgList}" var="org">
               <h:column>
               <f:facet name="header">
               <h:outputText value="Name" />
               </f:facet>
               <h:outputText value="#{org.name}"/>
               </h:column>
               <h:column>
               <f:facet name="header">
               <h:outputText value="Code" />
               </f:facet>
               <s:link value="#{org.code}" action="#{orgmanager.selectOrg}" propagation="join"/>
               </h:column>
               <h:column>
               <f:facet name="header">
               <h:outputText value="Description" />
               </f:facet>
               <h:outputText value="#{org.description}"/>
               </h:column>
               <h:column>
               <f:facet name="header">
               <h:outputText value="Level" />
               </f:facet>
               <h:outputText value="#{org.orgLevel.name}"/>
               </h:column>
              </h:dataTable>
              </h:form>
              </body>
              </html>
              


              The code for the bean is
              
              @Stateful
              @Scope(ScopeType.CONVERSATION)
              @Name("orgmanager")
              @Conversational(ifNotBegunOutcome="menu")
              public class OrgManagerBean implements OrgManager, Serializable {
               @Logger
               private Log log;
              
               @PersistenceContext(type = EXTENDED)
               private EntityManager em;
              
               @In(create=true,required = false) @Out(required = false)
               private Org orgEntry;
              
               @EJB OrgDAO orgDAO;
               @EJB OrgLevelDAO orgLevelDAO;
              
               @Out(required = false)
               private List<String> parentOrgCodes = new ArrayList<String>();
               @Out(required = false)
               private List<SelectItem> orgLevels = new ArrayList<SelectItem>();
              
               @DataModel
               private List<Org> orgList;
              
               @DataModelSelectionIndex
               private int orgIndex;
              
               private OrgLevel orgLevel;
              
               //@Begin(join=true)
               public String start() {
               //loadOrgs();
               //loadOrgLevels();
               return "org";
               }
              
               @End
               public String createOrg() {
               Org parentOrg = null;
               orgLevel = orgLevelDAO.findByName(orgLevelStr);
               orgEntry.setOrgLevel(orgLevel);
               em.persist(orgEntry);
               if (parentOrgCode != null) {
               parentOrg = orgDAO.findOrgByCode(parentOrgCode);
               OrgLink orgLink = new OrgLink(parentOrg, orgEntry, new Date());
               em.persist(orgLink);
               }
               return "org";
               }
              
               public String listOrgLevel() {
               // TODO Auto-generated method stub
               return null;
               }
               public void loadOrgLevels() {
               List<OrgLevel> list = orgLevelDAO.findAll();
               orgLevels = new ArrayList<SelectItem>();
               for (OrgLevel level : list) {
               orgLevels.add(new SelectItem(level.getName(), level.getName()));
               }
               log.info("orgLevels size = " + orgLevels.size());
               }
              
               @Begin(join=true) @Create
               public void init() {
               log.info("init() called");
               loadOrgs();
               loadOrgLevels();
               }
               public void loadOrgs() {
               orgList = orgDAO.findAll();
               }
              
               public String selectOrg() {
               log.info("Index =" + orgIndex);
               System.out.println("Index =" + orgIndex);
               orgEntry = orgList.get(orgIndex);
               log.info("Selected Code: " + orgEntry.getCode());
               return "org";
               }
              
               @Out(required = false)
               String codeErrorMsg;
              
               @In(required = false)
               String orgLevelStr;
              
               public void getParentOrgCodes() {
               log.info("-> getParentOrgCodes");
               if (parentOrgCodes != null)
               parentOrgCodes.clear();
               if (orgLevelStr != null) {
               orgLevel = orgLevelDAO.findByName(orgLevelStr);
               orgEntry.setOrgLevel(orgLevel);
               int level = orgEntry.getOrgLevel().getLevel();
               List<Org> list = orgDAO.findOrgsAboveLevel(level);
               for (Org o : list) {
               parentOrgCodes.add(o.getCode());
               }
              
               }
               }
              
               String orgCode;
              
               public void setOrgCode(String orgCode) {
               this.orgCode = orgCode;
               if (orgDAO.findOrgByCode(orgCode) != null) {
               codeErrorMsg = "Warning: \"" + orgCode +
               "\" is already in the system.";
               }
               else {
               codeErrorMsg = "";
               orgEntry.setCode(orgCode);
               }
               }
              
               public String getOrgCode() {
               return orgCode;
               }
              
               String parentOrgCode;
               public String getParentOrgCode() {
               return parentOrgCode;
               }
               public void setParentOrgCode(String pOC) {
               parentOrgCode = pOC;
               }
              
               @Destroy @Remove
               public void destroy() {
               log.info("destroy() called");
               }
              }
              


              Thanks....

              • 4. Re: long running conversation problem

                Hi Pete,

                Do you see anything obvious in the code that can cause the problem?

                Thanks.