0 Replies Latest reply on Mar 18, 2008 2:51 PM by William Woodman

    help: how do you pop a tab in a a4j:tabPanel from within an

    William Woodman Master

      Need help. Beginner here having shot at ajax/seam here so go gently

      I have created a main front page with several tabs.

      in my sample code on tab2 i have a form defined and and then an a4j:include - view file.

      this works okay i select the second tab and it renders the view and i get form action on the included view file.

      This is a wizard - its a record lister and a edit form view as a wizard pair.

      However - when i finish a conversation and direct back ot the first include view the app pops me back into the first front page on the first tab.

      how do config the pages or faces-config xml and trigger a reload of the second tab (where i first started the journey)

      I just dont know how to do this.

      heres the home page with the include on tab2.

      
      <ui:define name="body">
      
       <h:messages globalOnly="true" styleClass="message"/>
       <ui:param name="projectName" value="Wills project" />
      
       <rich:toolBar>
       <rich:toolBarGroup>
       <h:outputText value="#{projectName}" />
       </rich:toolBarGroup>
       <!-- @newMenuItem@ -->
       <rich:toolBarGroup location="right">
       <s:link view="/node.xhtml" value="Node"/>
       <s:link view="/enhanced node.xhtml" value="Enhanced Node Manager"/>
       <s:link view="/nodeList.xhtml" value="NodeList"/>
       <s:link view="/nodeManager.xhtml" value="NodeManager"/>
       <s:link view="/link.seam" value="Link" />
       <s:link view="/linkList.seam" value="LinkList" />
       </rich:toolBarGroup>
      </rich:toolBar>
      
      <rich:tabPanel switchType="ajax">
       <rich:tab label="welcome">
       <rich:panel>
       <f:facet name="header">Welcome!</f:facet>
       <p>This empty shell application includes:</p>
       <ul>
       <li>Ant build script</li>
       <li>Deployment to JBoss AS (EAR or WAR)</li>
       <li>Development and production profiles</li>
       <li>Integration testing using TestNG and Embedded JBoss</li>
       <li>JavaBean or EJB 3.0 Seam components</li>
       <li>JPA entity classes</li>
       <li>A configurable DataSource and JPA EntityManager</li>
       <li>Templated Facelets views</li>
       <li>RichFaces panels and tables</li>
       <li>Default CSS stylesheet</li>
       <li>Internationalization support</li>
       </ul>
       </rich:panel>
       </rich:tab>
       <rich:tab label="People" id="peopleTab">
       <h:form id="personListForm">
       <a4j:include viewId="/personList.xhtml" />
       </h:form> </rich:tab>
       <rich:tab label="Places" id="placesTab">
      
       </rich:tab>
      
      </rich:tabPanel>
      </ui:define>
      </ui:composition>
      


      then i have page like this - listing page

      
      <ui:define name="body">
      
       <a4j:outputPanel ajaxRendered="true">
       <h:messages globalOnly="true" styleClass="message"/>
       </a4j:outputPanel>
      
       <h1>Person List Manager</h1>
      
       <!-- form in higer level tab <h:form id="searchCriteria"> -->
       <fieldset>
      
       <h:inputText id="searchString"
       value="#{personList.searchString}" >
       <!-- comment out <a4j:support event="onkeyup" actionListener="#{nodeList.find()}"
       reRender="searchResults" /> -->
       </h:inputText>
        
       <a4j:commandButton id="findNodes" value="Find People"
       action="#{personList.resultList}"
       reRender="personSearchResults" />
        
      
       <a4j:status id="searchStringStatus">
       <f:facet name="start">
       <h:graphicImage value="/img/spinner.gif" />
       </f:facet>
       </a4j:status>
       <br/>
       <h:outputLabel for="pageSize" >Maximium Results</h:outputLabel>
        
       <!-- set the maxResults attribute which determines the page size to display -->
       <h:selectOneMenu value="#{personList.maxResults}" id="pageSize" >
       <f:selectItem itemLabel="2" itemValue="2"/>
       <f:selectItem itemLabel="4" itemValue="4"/>
       <f:selectItem itemLabel="5" itemValue="5"/>
       <f:selectItem itemLabel="10" itemValue="10"/>
       <f:selectItem itemLabel="20" itemValue="20"/>
       </h:selectOneMenu>
        <br />
       <!-- start a new node -->
       <a4j:commandButton action="new" value="New Person" />
       </fieldset>
       <!-- </h:form> -->
      
       <a4j:outputPanel id="personSearchResults">
       <div class="section">
       <h:outputText value="no nodes found"
       rendered="#{personList.resultList != null and nodeList.resultList.size==0}" />
       <rich:dataTable id="personList" var="person"
       value="#{personList.resultList}"
       rendered="#{not empty personList.resultList}">
       <rich:column width="10" >
       <f:facet name="header">Id</f:facet>
       #{person.id}
       </rich:column>
       <rich:column>
       <f:facet name="header">Node Type</f:facet>
       #{person.nodeType}
       </rich:column>
       <rich:column>
       <f:facet name="header">Name</f:facet>
       <s:link id="editPersonLink"
       value="#{person.name}"
       action="edit">
       <a4j:support event="onkeyup" reRender="personTab"/>
       </s:link>
       </rich:column>
       <rich:column>
       <f:facet name="header">Date</f:facet>
       #{person.lastUpdated}
       </rich:column>
       <rich:column width="3">
       <f:facet name="header">Action</f:facet>
       <s:button id="editNode"
       value="edit"
       action="edit">
       <a4j:support event="onkeyup" reRender="personTab"></a4j:support>
       </s:button>
       </rich:column>
       </rich:dataTable>
       </div>
       <div>
       <fieldset>
       <s:button view="/personList.xhtml"
       action="#{personList.firstPage}"
       rendered="#{personList.previousExists}"
       value="First Page |<">
       <a4j:support immediate="true" event="onkeyup" limitToList="true" reRender="personSearchResults"/>
       </s:button>
       <s:button view="/personList.xhtml"
       action="#{personList.previousPage}"
       rendered="#{personList.previousExists}"
       value="< Previous Page">
       <a4j:support immediate="true" event="onkeyup" limitToList="true" reRender="personSearchResults"/>
       </s:button>
       <s:button view="/personList.xhtml"
       action="#{personList.nextPage}"
       rendered="#{personList.nextExists}"
       value="Next Page >">
       <a4j:support event="onkeyup" limitToList="true" reRender="personSearchResults"/>
       </s:button>
       <s:button view="/personList.xhtml"
       action="#{personList.lastPage}"
       rendered="#{personList.nextExists}"
       value="Last Page >|">
       <a4j:support event="onkeyup" limitToList="true" reRender="personSearchResults"/>
       </s:button>
       </fieldset>
       </div>
       <div>
       <!-- end conversation -->
       <s:button view="/personList.xhtml"
       action="#{personList.clear}"
       value="Finish">
       </s:button>
       <!-- end conversation -->
       <s:button view="/personList.xhtml"
       action="reset"
       value="Reset">
       </s:button>
      
       </div>
       </a4j:outputPanel>
      
      
      
      </ui:define>
      
      </ui:composition>
      


      personList.clear , has an @End annotation - tidies up and returns "completed".

      my pages.xml has a rule

      ...
       <page view-id="/personList.xhtml">
       <navigation>
       <rule if-outcome="new">
       <render view-id="/person.xhtml"/>
       </rule>
       <rule if-outcome="edit">
       <render view-id="/person.xhtml"/>
       </rule>
       <rule if-outcome="complete">
       <render view-id="/personList.xhtml"/>
       </rule>
       <rule if-outcome="reset">
       <render view-id="/personList.xhtml"/>
       </rule>
       </navigation>
       </page>
      


      when i run this - and hit the finish button - the screen pops back to the main.xtml on the first tab and i completley lose my place.

      I want it to finsih the conversation, stay in tab 2 and restart the journey -

      how do i tell the code to do this?