8 Replies Latest reply on Apr 17, 2009 8:24 AM by Tom Schurmans

    2 times a4j:include on 1 page

    Tom Schurmans Newbie

      Hello,

      I have been working with Richfaces for about a month now, and I encountered a problem:

      I have my "main page", which consists out of 3 parts: A top part which is the main navigation, a west part which is my second navigation and a center part where my content goes.

      Now, for each menu I have a backup bean where I set the value a a variable (link, in my case).

      this is for example a link in my north part:

      <a4j:commandLink action="#{dropDownMenuBean.goUsers}" styleClass="links" reRender="submenu">Users</a4j:commandLink>
      


      goUsers sets the variable "link" in my bean to the page I want to go to. The tree in the submenu works the same, with another bean

      I then have my ajax includes:

      <a4j:include id="submenu" viewId="#{dropDownMenuBean.link}" />
      <a4j:include id="contentpanel" viewId="#{treeBean.link}" />
      


      When I only have one a4j:include on my page, everything works great. I click and the right page gets included. But when I have 2, everything gets messed up. The page I want to get included, just includes in the first a4j:include beneath the page that is already in there, very strange!

      So I went back to 1 include and removed the id of it, and it still worked.

      Is there any solution to my problem so I can have 2 dynamic includes on my page which don't mess up eachother?

      Thanks for your time!

        • 1. Re: 2 times a4j:include on 1 page
          Ilya Shaikovsky Master

          something wrong with just your page markup.. Could you please paste the snippets for page and includes fully. And check please the generated page with tidy validator plugin for FF.

          Also which RF version used?

          • 2. Re: 2 times a4j:include on 1 page
            Tom Schurmans Newbie

            I use 3.2.2 SR1

            this is the code of the full page:

            <!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:a4j="http://richfaces.org/a4j"
             xmlns:rich="http://richfaces.org/rich"
             xmlns:f="http://java.sun.com/jsf/core"
             xmlns:ui="http://java.sun.com/jsf/facelets"
             xmlns:c="http://java.sun.com/jstl/core">
            
            <head>
            <title>Reservations</title>
            <script type="text/javascript" src="scripts/jquery.js"></script>
            <script type="text/javascript" src="scripts/jquery.layout.js"></script>
            <script type="text/javascript">
            jQuery.noConflict();
            jQuery(document).ready(function () {
             jQuery('body').layout({ applyDefaultStyles: true });
            });
            </script>
            <style>
            .links {
             text-decoration: none;
             color: black;
            }
            </style>
            </head>
            <body>
            <div class="ui-layout-north">
             <ui:include src="menuBoven.xhtml" />
            </div>
            <div class="ui-layout-west">
             <ui:include src="#{dropDownMenuBean.link}" />
            </div>
            <div class="ui-layout-center">
             <a4j:include viewId="#{treeBean.link}" />
            </div>
            </body>
            </html>


            thank you!

            • 3. Re: 2 times a4j:include on 1 page
              Tom Schurmans Newbie

              sorry, that was the wrong code, with only 1 ajax include, which works, this is the one with 2 ajax includes:

              <!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:a4j="http://richfaces.org/a4j"
              xmlns:rich="http://richfaces.org/rich"
              xmlns:f="http://java.sun.com/jsf/core"
              xmlns:ui="http://java.sun.com/jsf/facelets"
              xmlns:c="http://java.sun.com/jstl/core">


              Reservations



              jQuery.noConflict();
              jQuery(document).ready(function () {
              jQuery('body').layout({ applyDefaultStyles: true });
              });


              .links {
              text-decoration: none;
              color: black;
              }




              <ui:include src="menuBoven.xhtml" />


              <a4j:include id="submenu" viewId="#{dropDownMenuBean.link}" />


              <a4j:include id="contentpanel" viewId="#{treeBean.link}" />


              • 4. Re: 2 times a4j:include on 1 page
                Tom Schurmans Newbie

                I seem to have forgot code tags, and editing posts doesn't work:

                <!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:a4j="http://richfaces.org/a4j"
                 xmlns:rich="http://richfaces.org/rich"
                 xmlns:f="http://java.sun.com/jsf/core"
                 xmlns:ui="http://java.sun.com/jsf/facelets"
                 xmlns:c="http://java.sun.com/jstl/core">
                
                <head>
                <title>Reservations</title>
                <script type="text/javascript" src="scripts/jquery.js"></script>
                <script type="text/javascript" src="scripts/jquery.layout.js"></script>
                <script type="text/javascript">
                jQuery.noConflict();
                jQuery(document).ready(function () {
                 jQuery('body').layout({ applyDefaultStyles: true });
                });
                </script>
                <style>
                .links {
                 text-decoration: none;
                 color: black;
                }
                </style>
                </head>
                <body>
                <div class="ui-layout-north">
                 <ui:include src="menuBoven.xhtml" />
                </div>
                <div class="ui-layout-west">
                 <a4j:include id="submenu" viewId="#{dropDownMenuBean.link}" />
                </div>
                <div class="ui-layout-center">
                 <a4j:include id="contentpanel" viewId="#{treeBean.link}" />
                </div>
                </body>
                </html>


                • 5. Re: 2 times a4j:include on 1 page
                  Ilya Shaikovsky Master

                  please pack the sample into war and share.

                  • 6. Re: 2 times a4j:include on 1 page
                    Tom Schurmans Newbie

                    is it ok if I email it? Do you also need a .sql file for the database?

                    • 7. Re: 2 times a4j:include on 1 page
                      Ilya Shaikovsky Master

                      sure you could send it. Also simplify please as possible. (at least to use mock data)

                      • 8. Re: 2 times a4j:include on 1 page
                        Tom Schurmans Newbie

                        before bugging you with the whole project, I tried doing the same thing on a simple page:

                        1 panel with 2 buttons (which changed the value of the link variable in de backing beans). Same result. The page I want to include just includes in the first panel.

                        Anyone has example code of 2 a4j:includes on 1 page (where you get the viewId from a value in the backing bean)?