14 Replies Latest reply on May 5, 2010 5:37 AM by ramy Hassan

    Problem in Delayed Rendering of Ajax-powered Components

    ramy Hassan Novice

      Hello there

      The case is as follows:

      I'm creating a Simple page containing a menu and an "area" that should hold a tabbed panel having Ajax tab switch.

      The problem is that the tab switching does not work in case the tabbed panel is not rendered initially (i.e. its rendered attribute is false until a menu item is selected for example).

      The tabbed panel is rendered when the menu item is selected, but tab switching is not working!


      If I would summarize this issue, I could say that "Ajax-based components do not work well with conditional rendering".
      So is this a bug, limitation, or I'm not doing it the correct way?

      Thanks in advance for any help.

      and this is the Code of the Page :

      
      <html>
       <head>
       <title>RichFaces Greeter</title>
       </head>
       <body>
       <f:view>
       <h:panelGrid columns="2" border="1" id="wholepage">
      
       <rich:panelMenu id="jpanelmenu">
       <rich:panelMenuGroup id="jpanelmenugroup" label="Choose your destiny"
       action="#{bean.action}">
       <rich:panelMenuItem id="page1_menuitem_id" label="Page 1"
      
      
       action="#{bean.action}">
       <f:param value="page1" name="page"/>
       </rich:panelMenuItem>
       </rich:panelMenuGroup>
       </rich:panelMenu>
      
       <f:subview id="subview_for_ajax" >
       <rich:panel id="richpanel_for_ajax">
       <h:outputText id="Outputtext" value="You selected #{bean.page}" />
       <br /><br />
      
       <rich:tabPanel id="car" switchType="ajax" width="40%" headerAlignment="right" rendered="#{bean.page == 'page1'}">
      
       <rich:tab id="richtab_bmw_tab_id" label="BMW">
      
       This is BMW
      
       </rich:tab>
      
       <rich:tab id="richtab_toyota_tab_id" label="Toyota">
       This is Toyota
       </rich:tab>
      
       <rich:tab id="richtab_jeep_tab_id" label="Jeep">
      
       This is Jeep
      
       </rich:tab>
      
       </rich:tabPanel>
      
       </rich:panel>
       </f:subview>
      
       </h:panelGrid>
       </f:view>
       </body>
      </html>
      
      
      


      and this is the Managed Bean Code :
      public class Bean {
      
       /** Creates a new instance of Bean */
       public Bean() {
       }
       String page="page1";
      
       public String getPage() {
       FacesContext context=FacesContext.getCurrentInstance();
       Map<String,String> params=context.getExternalContext().getRequestParameterMap();
       page=params.get("page");
       if(page==null ||page.equals(""))
       {
       return "page3";
       }
       return page;
       }
      
       public void setPage(String page) {
       this.page = page;
       }
      
       public String action()
       {
       //returning null based on richfaces guide section 5.6.5
       return null;
       }
      }
      
      


      Thanks :)