3 Replies Latest reply on Sep 18, 2007 4:30 AM by tkalactomo

    how to use switchtype ajax in rab panel?


      HI,

      I want to use switch type "ajax" in rich:tabPanel. each tab should be loaded using the ajax calls. how can i do that? is there any extra code needs to be added for that.

        • 1. Re: how to use switchtype ajax in rab panel?

          Hy you do that like this:

          <r:tabPanel switchType="ajax">
          <r:tab label="Tab 1">
          
          </r:tab>
          ...
          

          I think that you should read the
          developers guide and checkout the richfaces livedemo!

          • 2. Re: how to use switchtype ajax in rab panel?

            Yes..I can do this. But my doubt is what is the method to update Tab contents. I am using actionListener to update while clicking on the tab. Is it correct approach or any other better way to load the tab data. Here is the code i have writen :

            <rich:tabPanel switchType="ajax" >
             <rich:tab label="Tab1" name="Tab1" actionListener="#{ajaxPoc.list1}>
             <rich:dataTable value="#{ajaxPoc.list1}" var="sys">
             <rich:column>
             <h:outputText value="#{sys}"/>
             </rich:column>
             </rich:dataTable>
             </rich:tab>
             <rich:tab label="Tab2" name="Tab2" actionListener="#{ajaxPoc.list2}">
             <rich:dataTable value="#{ajaxPoc.list2}" var="sys">
             <rich:column>
             <h:outputText value="#{sys}"/>
             </rich:column>
             </rich:dataTable>
             </rich:tab>
            


            • 3. Re: how to use switchtype ajax in rab panel?

              Try something like this:

              <r:tabPanel switchType="ajax" binding="#{tab}">
              <r:tab label="Tab 1" name="firstTab">
              <a:include rendered="#{tab.selectedTab=='firstTab'}"
              viewId="Tab1Content.jsp" />
              </r:tab>
              
              <r:tab label="Tab 2" name="secondTab">
              <a:include rendered="#{tab.selectedTab=='secondTab'}"
              viewId="Tab2Content.jsp" />
              </r:tab>
              ...
              


              bean looks like this:
              @Name("binding")
              @Scope(ScopeType.CONVERSATION)
              public class Binding {
              @In(required=false,create=true)
              @Out(required=false)
              public HtmlTabPanel tab;
              
              public void createBinding(){
              //this method doesn't do nothing, just outjects the tab
              }
              ...
              

              I have called the createBinding() method from the pages.xml because i need
              the tab in conversation for the binding.
               <page view-id="../Tabs.jsp"
               login-required="true" action="#{binding.createBinding}">
               <begin-conversation join="true" pageflow="tab"
               flush-mode="MANUAL" />
               </page>
              


              After all I don't understand why you need this because when the swith-type="ajax"
              is set on the tab panel not whole tab content of every tab on the page is loaded, only that which is
              selected,or am I wrong?