4 Replies Latest reply on Oct 18, 2007 8:32 AM by damianharvey

    Seam 2 breaks all-on-one-page application

    damianharvey

      I've recently upgraded to Seam 2.0.0.CR2 and another thing that has broken in my application is resetting a page after an update. Many of my pages are all-on-the-one-page types with the form on the left and the table of records on the right.

      Under Seam1.2.1.GA in my persist() methods I would call:

      Contexts.removeFromAllContexts("vesselHome");

      I would then redirect back to the same page and the instance would be clear.

      Under Seam 2.0.0.CR2 this doesn't happen. The instance remains (ie. the fields in the form all retain the persisted values).

      What do I have to do to make this work in Seam 2?

      Thanks,

      Damian.

        • 1. Re: Seam 2 breaks all-on-one-page application
          gavin.king

          You'll need to give us way more information than that.

          • 2. Re: Seam 2 breaks all-on-one-page application
            damianharvey

            Sure thing.

            I have an MaintainVessels.xhtml page like this:

            <h:form>
            <!-- Vessel name -->
            <s:decorate id="validateName" template="/layout/edit.xhtml">
             <ui:define name="label">#{messages['vessels.vesselName']}</ui:define>
             <h:inputText tabindex="1" styleClass="inputField" id="vesselName" value="#{vesselHome.instance.vesselName}" required="true" size="40" maxlength="150">
             <a:support event="onchange" reRender="validateName"/>
             </h:inputText>
            </s:decorate>
            other fields....
            <h:commandButton value="#{messages['saveButton']}" styleClass="button" action="#{vesselHome.persist}" rendered="#{!vesselHome.managed}"/>
            </h:form>
            <h:form>
            <rich:dataTable styleClass="dataTable" id="vesselTable" value="#{vesselList.allVessels}" var="vesselEntry" rows="20">
             <rich:column>
             <f:facet name="header">#{messages['vessels.carrier']}</f:facet>
             <h:outputText value="#{vesselEntry.company.companyName}"/>
             </rich:column>
            more columns....
             <rich:column>
             <s:link action="#{vesselHome.find}"
             title="#{messages['edit.entry']}">
             <f:param name="vesselVesselId" value="#{vesselEntry.vesselId}"/>
             <h:graphicImage url="/img/edit.png" border="0"/>
             </s:link>
             <s:link action="#{vesselHome.remove}"
             onclick="return confirm('#{messages['confirm.deleteEntry']}');"
             title="#{messages['delete.entry']}">
             <f:param name="vesselVesselId" value="#{vesselEntry.vesselId}"/>
             <h:graphicImage url="/img/cross.png" border="0"/>
             </s:link>
             </rich:column>
            </rich:dataTable>
            </h:form>
            


            And my VesselHome persist method looks like this:
            @Override
            @Transactional
            public String persist() {
            
             //Set status to active
             getInstance().setStatus(VesselStatus.ACTIVE);
            
             String status = super.persist();
            
             //Remove from Conversation context
             Contexts.removeFromAllContexts("vesselHome");
            
             return status;
            }
            


            The MaintainVessels.page.xml has the following rules:
            <?xml version="1.0" encoding="UTF-8"?>
            <page xmlns="http://jboss.com/products/seam/pages"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://jboss.com/products/seam/pages http://jboss.com/products/seam/pages-2.0.xsd" login-required="true">
             <begin-conversation join="true"/>
             <restrict>#{s:hasRole('VESSEL EDITOR') or s:hasRole('VESSEL APPROVER')}</restrict>
             <param name="vesselVesselId" value="#{vesselHome.vesselVesselId}"/>
             <navigation from-action="#{vesselHome.persist}">
             <redirect view-id="/secure/MaintainVessels.xhtml"/>
             </navigation>
             <navigation from-action="#{vesselHome.update}">
             <redirect view-id="/secure/MaintainVessels.xhtml"/>
             </navigation>
             <navigation from-action="#{vesselHome.remove}">
             <redirect view-id="/secure/MaintainVessels.xhtml"/>
             </navigation>
             <navigation from-action="#{vesselHome.reset}">
             <redirect view-id="/secure/MaintainVessels.xhtml"/>
             </navigation>
            
            </page>
            


            Under Seam 1.2.1.GA I could fill in the values for a new Vessel and click save. This would call the persist() method. Once that had finished the page.xml would redirect it back to the MaintainVessels page and the values in the fields would be blank as no VesselHome existed in the context.

            This doesn't happen under Seam 2.0.0.CR2. When I click save, the instance is persisted and the page is redirected fine, but the values exist.

            I've tried adding an <end-conversation/> to the MaintainVessel.page.xml but this will only work if I redirect to another page and not back to the same page.

            Cheers,

            Damian.

            • 3. Re: Seam 2 breaks all-on-one-page application
              damianharvey

              This has turned out to be the same (or very similar) issue as in this other post of mine:
              http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4095424

              I went back to an old 1.3.0.ALPHA version of my application and found that the culprit was one of the following jars:
              jboss-el.jar
              jboss-seam-gen.jar (almost definitely not this one)
              jboss-seam-ioc.jar

              For that version I just replaced the jars with the ones from the working version. I still can't solve this under Seam 2.0.0.CR2 but does this give an indication of where the problem may lie?

              Thanks,

              Damian.

              • 4. Re: Seam 2 breaks all-on-one-page application
                damianharvey

                org.jboss.seam.framework.Home.clearInstance() was introduced in Seam 2.0.0.CR1. So I call this after I clear the contexts. Works fine.

                Cheers,

                Damian.