13 Replies Latest reply on Jan 14, 2009 3:33 AM by traysa b

    How to use panelMenu

    ZJ DA Newbie

      It should be a common use case, but I have struggled for months and could not find an answer. My application has common header, footer and rich:panelMenu on the left side. The right side is the main working area which displays content based on the panelMenu selection as well as other commands. For example, when “Accountsâ€� is selected in the panelMenu, the working area will display a list of accounts and buttons "New Account", "View Detail", and so on. When one of the buttons is clicked, the working area will display a different page, for example, to create a new account while the header, footer and panelMenu are not affected at all.

      I migrated my application from MyFaces and Tiles to RichFaces since I wanted to use ajax to avoid full page update. It seems to me that only way is to use a4j:include:

      <rich:panel id="mainframe">
      <a4j:include id="content" viewId="#{panelMenu.target}"/>
      </rich:panel>
      


      Whenever I want to navigate to another content page, I change the back bean value and reRender the mainframe. It works fine. However, it breaks the standard JSF navigation rule. Can anyone suggest a better way to do it?

      Thanks,
      -ZJ

        • 1. Re: How to use panelMenu
          traysa b Newbie

          hiya,

          I'm in the same situation. The problem with the include is that I sometimes have several contents in my working area when I switch between the menu items. Can someone explain to me why this happen?

          thx,
          traysa

          • 2. Re: How to use panelMenu
            Nick Belaevski Master

            ZJ,

            In principle, you can put panel menu inside the same a4j:include and use JSF navigation.

            Traysa,

            Can you add some more information?

            • 3. Re: How to use panelMenu
              ZJ DA Newbie

              Hi Traysa,

              Thank you for your suggestion. I understand that all my pages can include the header, footer, and panel menu using a4j:include and use JSF navigation rules. However, in this way, the whole page has to be updated when navigating to a different page. What I want is that only the working area will be updated (not the header, footer and panel menu). Is there any way to use JSF navigation rules to partially update a page? I saw that someone tried to use the target attribute of the menu item to update a area, but it did not work.

              Regards,
              -ZJ

              • 4. Re: How to use panelMenu
                traysa b Newbie

                hiya,

                I've got the same requirements as zjda. So I build a fixed header, menu and working area. The working area contains the <a4j:include>.
                Then I build a NavigationController (scope: application):

                public class NavigationController {
                
                 //Url of the page to show
                 private static String url;
                
                
                 //Constructor
                 public NavigationController(){
                 NavigationController.url = "";
                 }
                
                
                 //Changes the url-adress for the include
                 public static void navigateTo(String url) {
                 NavigationController.url = url;
                 }
                
                
                 //Setter
                 public void setUrl(String url) {
                 NavigationController.url = url;
                 }
                
                
                 //Getter
                 public String getUrl() {
                 if ((url.equals(""))||(url == null))return ERROR_PAGE;
                 else return url;
                 }
                
                }


                on the mainpage:

                <a4j:include viewId="#{navigationController.url}" layout="block" rendered="true"/>


                So when I click a button in the menu, it changes the url in the NavigationController via function 'navigateTo' and rerenders the <a4j:include>.
                It works almost fine. Just the ugly thing that I suddenly have several url-contents in the include.

                I also look for a nicer solution...

                regards,
                traysa

                • 5. Re: How to use panelMenu
                  Jens Mueller Novice

                  I'm facing a similar scenario. From what i've found the only reliable way for proper navigation is thru jsf navigation.

                  • 6. Re: How to use panelMenu
                    traysa b Newbie

                    do you have a solution with jsf navigation and a fixed header/footer/menu?

                    • 7. Re: How to use panelMenu
                      Jens Mueller Novice

                      Not really. The only thing i can think of is to make/simulate a click from a hidden button situated in your working area. However you'd then have to put a button on every workin area which might be quite cumbersome.
                      i'd be grateful myself if someone could shed some light on this.

                      • 8. Re: How to use panelMenu
                        Daniel Ku Newbie

                        Why not using Facelets for templating? You can define a header, footer etc. than define a layout.xhtml where you insert header, footer ... and define the "main" frame. Make use of <ui:insert>. The only thing you have to do, is referencing this template in each site you create.

                        You can find more informations about Facelets here:
                        http://www.ibm.com/developerworks/java/library/j-facelets/

                        • 9. Re: How to use panelMenu
                          traysa b Newbie

                          hello DanielK, thanks for your reply.

                          I'm trying to use Facelets, but somehow I can't get the right configuration, so that I always get runtime errors, like: 'A4J' is not defined. The site is shown, but I can't use any rich components.

                          can somebody help me out?

                          thx,
                          traysa

                          • 10. Re: How to use panelMenu
                            Ilya Shaikovsky Master

                            traysa, you could create sample for us.. and we will check it ;) as for me this will be faster solution.

                            • 11. Re: How to use panelMenu
                              traysa b Newbie

                              hello ilya_shaikovsky,

                              i tried to create a smaller sample. now i have the problem that i, when i navigate, always get the http status 404.
                              i don't know where to put up the sample...

                              thx,
                              traysa


                              • 12. Re: How to use panelMenu
                                Ilya Shaikovsky Master

                                send me directly after complete. (email in profile)

                                • 13. Re: How to use panelMenu
                                  traysa b Newbie

                                  war-file is sent.

                                  thx