10 Replies Latest reply on Jan 20, 2011 11:47 AM by simplicity

    Nested Rich Output Components with SwitchType AJAX doesnt wo

      Hi,

      We are using Rich Faces 3.3.1 GA, along with Facelets 1.1.14, JSF 1.2(RI) and Servlets 2.4 (Weblogic 9.2). (can't change version now :-( )

      In our application, we have the following setup:
      A rich:tabPanel containing 3 or more rich:simpleTogglePanels, which in turn contains a rich:tabPanel. All the components have their switchType as AJAX. Web.XML has an entry - facelets.BUILD_BEFORE_RESTORE to TRUE.

      If facelets.BUILD_BEFORE_RESTORE is false, everything seems to work normally. But the moment I change it to TRUE, I can see the AJAX request going through fine, but, the screen doesn't re-render. effectively not opening/closing the simple toggle panels/ switching the tabs. I am able to replicate the problem with TomCat aswell.


      Meanwhile, with BUILD_BEFORE_RESTORE set to FALSE, the page works fine on a POC project. But it doesn't seem to like the rest of the setup in the project. The tabswitch + open-simpleTogglePanel works fine on FireFox, but close STP doesnt. The setup doesn't work with any other browse at all. Has anyone faced a similar situation?

      I am currently in the process of determining what is causing the trouble in the full project setup. Couldn't trace it.

        • 1. Re: Nested Rich Output Components with SwitchType AJAX doesn
          nbelaevski

          Hi,

          Please post page code.

          • 2. Re: Nested Rich Output Components with SwitchType AJAX doesn

            XHTML code for problem 1.

            <!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:h="http://java.sun.com/jsf/html"
             xmlns:f="http://java.sun.com/jsf/core"
             xmlns:ui="http://java.sun.com/jsf/facelets"
             xmlns:a4j="http://richfaces.org/a4j"
             xmlns:rich="http://richfaces.org/rich">
             <head>
             <title>Nested Rich Output Componets test</title>
             </head>
            <body>
            
            <rich:tabPanel id="outerTab" switchType="ajax">
             <rich:tab id="FirstTab" label="Summary Tab">
             This is the first outer tab. this will be the default tab.
             </rich:tab>
            
             <rich:tab id="SecondTab" label="Details Tab">
             This tab contains two simple toggle panels, which in turn has a rich: tabpanel
             <rich:simpleTogglePanel id="firstTogglePanel"
             label="Detail Section 1" switchType="ajax" opened="false">
             there should be two rich:tabs below this.
             <rich:tabPanel id="innerTabPanel" switchType="ajax">
             <rich:tab id="detailSection1Tab1" label="Details 1.1">
             This contains the details for Section 1 - tab 1
             </rich:tab>
             <rich:tab id="detailSection1Tab2" label="Details 1.2">
             This contains the details for Section 1 - tab 2
             </rich:tab>
             </rich:tabPanel>
             :
             </rich:simpleTogglePanel>
             <rich:simpleTogglePanel id="detailSection2" switchType="ajax" opened="false" label="Detail Section 2">
             This contains details about section 2.
             </rich:simpleTogglePanel>
            
             </rich:tab>
            </rich:tabPanel>
            </body>
            
            </html>
            
            


            The above code works if web.xml has the following entry


            <context-param>
             <param-name>facelets.BUILD_BEFORE_RESTORE</param-name>
             <param-value>false</param-value>
             </context-param>
            


            if I change the param-value to "true", the above code fails.


            The second part of the problem is that, when I put the above XHTMLfile into my master application, it stops working even if the param-value is "false". I am not sure what exactly is happenning. I can see the AJAX request using FIREBUG, but, the screen doesn't refresh. The appliaction has a lot of filters attached, and has a few pages in STRUTS 1.2 as well.

            thanks in advance.


            • 3. Re: Nested Rich Output Components with SwitchType AJAX doesn

              Sorry, missed it. The original POC had a proper a4j:form as well. I had also tried adding one or more a4j:outputPanel with ajaxRendered=true/false, in vain.

              Something like this:

              <!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:h="http://java.sun.com/jsf/html"
               xmlns:f="http://java.sun.com/jsf/core"
               xmlns:ui="http://java.sun.com/jsf/facelets"
               xmlns:a4j="http://richfaces.org/a4j"
               xmlns:rich="http://richfaces.org/rich">
              <head>
              <title>Nested Rich Output Componets test</title>
              </head>
              <body>
              <a4j:form id="nestedComponentsForm">
               <a4j:outputPanel id="nestedPanel">
               <rich:tabPanel id="outerTab" switchType="ajax">
               <rich:tab id="FirstTab" label="Summary Tab">
               This is the first outer tab. this will be the default tab.
               </rich:tab>
              
               <rich:tab id="SecondTab" label="Details Tab">
               <a4j:outputPanel id="secondTabOutputPanel" ajaxRendered="true">
               This tab contains two simple toggle panels, which in turn has a rich: tabpanel
               <rich:simpleTogglePanel id="firstTogglePanel"
               label="Detail Section 1" switchType="ajax" opened="false">
               there should be two rich:tabs below this.
               <rich:tabPanel id="innerTabPanel" switchType="ajax">
               <rich:tab id="detailSection1Tab1" label="Details 1.1">
               This contains the details for Section 1 - tab 1
               </rich:tab>
               <rich:tab id="detailSection1Tab2" label="Details 1.2">
               This contains the details for Section 1 - tab 2
               </rich:tab>
               </rich:tabPanel>
               </rich:simpleTogglePanel>
               <rich:simpleTogglePanel id="detailSection2" switchType="ajax"
               opened="false" label="Detail Section 2">
               This contains details about section 2.
               </rich:simpleTogglePanel>
               </a4j:outputPanel>
               </rich:tab>
               </rich:tabPanel>
               </a4j:outputPanel>
              </a4j:form>
              </body>
              
              </html>
              


              • 4. Re: Nested Rich Output Components with SwitchType AJAX doesn

                Additional Info:

                In the above example, I tried the following

                Changed all switch types from AJAX to CLIENT, except for the first SimpleTogglePanel.
                The BUILD_BEFORE_RESTORE was still TRUE


                The StglPnl opened nicely on the first click, but refused to close at all.

                there is no nested "ajax" components in this example, but it still fails.

                • 5. Re: Nested Rich Output Components with SwitchType AJAX doesn

                  I got a partial solution so far:

                  I realized that if the Simple Toggle Panel is embedded within an AJAX Tab Panel, the state information goes for a toss. To overcome this, I added a hidden field with the state of the simpleTogglePanel. I set/reset this hiddenfield using "onexpand" and "onCollapse". I then use a a manged bean's value to the "opened" attribute of the SimpleTogglePanel.

                  What I am wondering is this: Why does the STP loose the status if embedded within a ajax tabPanel, but retains the status if it is the first component.

                  I am still unable to get an ajax switching tab pannel embedded within a ajax switching stp (see sample code in my prev. post).

                  Any pointers are welcome.

                  • 6. Re: Nested Rich Output Components with SwitchType AJAX doesn
                    ilya_shaikovsky

                    checked with the code

                     <rich:tabPanel switchType="ajax">
                     <rich:tab label="First">
                     Here is tab #1
                     </rich:tab>
                     <rich:tab label="Second">
                     Here is tab #2
                     <rich:simpleTogglePanel opened="false" switchType="ajax">
                     <rich:tabPanel switchType="ajax">
                     <rich:tab label="First">
                     Here is tab #1
                     </rich:tab>
                     <rich:tab label="Second">
                     Here is tab #2
                     </rich:tab>
                     <rich:tab label="Third">
                     Here is tab #3
                     </rich:tab>
                     </rich:tabPanel> </rich:simpleTogglePanel>
                     </rich:tab>
                     <rich:tab label="Third">
                     Here is tab #3
                     </rich:tab>
                     </rich:tabPanel>
                    


                    with default build_before_restore. (richfaceas-demo environment).. all tabs wrapper and nested switches fine. toggle panel also. after I'm switching the wrapper tabs and then returns to tab 2 - previous state of toggle and included tab restored.

                    checked with 3.3.3 SNapshot under tomcat 6

                    • 7. Re: Nested Rich Output Components with SwitchType AJAX doesn

                      Thanks Ilya.

                      the default build_before_restore is "false". And the code does work with default value.

                      It starts creating problems, when i change it to "true".

                      I tried running your example with BUILD_BEFORE_RESTORE as "true" and it did not work.

                      • 8. Re: Nested Rich Output Components with SwitchType AJAX doesn

                        Finally, I have got all the following components working with switch type AJAX:


                        Level 1: rich:tabPanel (Switch type AJAX / SERVER)

                        Level 2: rich:simpleTogglePanel (Switch type AJAX / SERVER)

                        Level3: rich:tabPanel (Switch type AJAX / SERVER)

                        Level4: h:selectOneRadio with ajaxSupport





                        The above listed components weren't working as documented, when they are nested within each other and with "facelets.BUILD_BEFORE_RESTORE" set to TRUE in web.xml.

                        To make these work, I had to add the following work-arounds:
                        For Simple Toggle Panel:
                        The state of the toggle panel (opened/closed) had to be maintained externally by code. I had to write a combination of javascript, a hidden input and methods in the managed bean to retrieve properties directly from the request object. (JSF Phase 1 - view creation requires the state of the simple toggle panel, but is not available in the managed bean until Phase 2)

                        For tabPanel and radio buttons
                        This was solved by adding a a4j:region around the particular components.

                        I still don't understand why these worked if they were the first component under the form, but doesn't work when it is nested within another AJAX Output Component, without any extra work.


                        Should I raise a JIRA/bug on this item?

                        • 9. Re: Nested Rich Output Components with SwitchType AJAX doesn
                          ilya_shaikovsky

                          I'll check it additionally. Thanks for your investigations and updates! https://jira.jboss.org/jira/browse/RFPL-259

                          • 10. Re: Nested Rich Output Components with SwitchType AJAX doesn
                            simplicity

                            Hi Ilya,

                             

                            I have a question about https://jira.jboss.org/jira/browse/RFPL-259.

                             

                            I am using richfaces 3.3 with MyFaces (JSF 1.2) and I have a problem of duplicate Id when iterating with c:forEach instruction. Not all the time but often after refreshing area.

                             

                            I have tried to use the BUILD_BEFORE_RESTORE to solve the problem (and it solves the problem), but dataGrid doesn't render at the first click (one of some problems detected).

                             

                            Do you plan to solve the Jira problem ? Or is there another way to resolve this problem ?

                             

                            Regards,

                             

                            Fabrice