4 Replies Latest reply on Oct 14, 2007 7:02 PM by Danilo Cubrovic

    dropdownmenu dinamically

    Danilo Cubrovic Newbie

      I started to use seamcr2 and needed to create dropdown menu dinamically.
      First I tried what's most logically to me to create this menu in my menu.xthml page.

      dropdown menu still doesnt have some data attribute to conect them to some data in my bean.

      I tried to achive this with ui:repeat bu have no succes with it.


      Now I tried to do that with binding attribute and to create menu in my source code (even so I think that such mix of presentation and logic isn't pretty at all...) but I coludn't achive that cause of lots of deployment error or classnotfound error or so and so.

      Can anyone help me to solve this problem?
      I read a tons of pages and tried a lots of stuff here but so far no access.

      Things are more complicated because I used seam CR2 witch distrubuted richfaces 3.1 and separate those jars (api in ear/lib and impl and ui i WEB-INF/lib ) whitch I think is great approach but some solutions that exists maybe works with older versions but not with this approach.

      I dont see way to create menu just by using this api.jar ?!

      I even though about dynamically create xml file but I dropped that idea cause menu will be different for different users so cant used this desparete solution :)

      tia

        • 1. Re: dropdownmenu dinamically
          Danilo Cubrovic Newbie

          Nobody have a clue?!

          • 2. Re: dropdownmenu dinamically
            Pete Muir Master

            Why don't you post some code - just ranting doesn't normally produce a response.

            • 3. Re: dropdownmenu dinamically
              Danilo Cubrovic Newbie

              Try too much combination to post it all there.
              Here is the latest simple combination that I use while trying too resolve this isue.

              in menu-adm.xhtml

              <rich:toolBar xmlns="http://www.w3.org/1999/xhtml"
               xmlns:ui="http://java.sun.com/jsf/facelets"
               xmlns:h="http://java.sun.com/jsf/html"
               xmlns:f="http://java.sun.com/jsf/core"
               xmlns:s="http://jboss.com/products/seam/taglib"
               xmlns:c="http://java.sun.com/jsp/jstl/core"
               xmlns:a4j="http://richfaces.org/a4j"
               xmlns:rich="http://richfaces.ajax4jsf.org/rich">
               <rich:toolBarGroup>
               <h:outputText value="#{projectName}:" />
               <s:link view="/adm.xhtml" value="Home" />
               </rich:toolBarGroup>
              
               <rich:toolBarGroup binding="#{managerMenuBean.menu}"></rich:toolBarGroup>
               <rich:toolBarGroup location="right">
               <h:outputText value="Welcome, #{identity.username}"
               rendered="#{identity.loggedIn}" />
               <s:link view="/login.xhtml" value="Login"
               rendered="#{not identity.loggedIn}" />
               <s:link view="/home.xhtml" action="#{identity.logout}" value="Logout"
               rendered="#{identity.loggedIn}" />
               </rich:toolBarGroup>
              </rich:toolBar>
              



              and in bean

              public HtmlToolBarGroup getMenu(){
               return new HtmlToolBarGroup();
               }


              tried it with a lot of different combination.
              Positioning jars in ear , WEB-INF/lib

              changing Java2ClassLoadingCompliance and UseJBossWebLoader

              and in every combination it neds up with deployment or runtime error classnotfound.

              I intentionally doesn't provide any code at first cause i didn want to limit suggestions but to find out any valid way that you use for creating dinamically menu in seam (CR2) environment.

              Currently code doesn;t create no meu as you see just empty Toolbargroup but it's the same problem with cleaner simpler code.

              When I produce standard jsf component same way (HTMLOutputText) that works just fine.






              • 4. Re: dropdownmenu dinamically
                Danilo Cubrovic Newbie


                I somehow make it work.

                I use solution already posted somewhere
                true

                but I had to change

                public HtmlToolBarGroup getMenu(){
                return new HtmlToolBarGroup();
                }

                to

                public UIComponent getMenu() {
                return new HtmlToolBarGroup();
                }

                because if i dont classnotfound exception was thrown during deployment ?!

                This seems more like a hack insted of legitible solution.

                So question still stands.
                How richfaces/seam constructors think those code should be designed and coded and is this a bug or my missunderstanding of valid use or what...

                I really thrilled about seam/richfaces kind of creating webapps and anxious to use it but those little things that cause a lot of wasted time and influence productivity can be pretty frustrated.

                I submit my "solution" to save some others guy time.

                Furthermore I had to setId-s to menus in code to make it work which is kind of expected so my final (still only for testing) method looks like

                public UIComponent getMenu() {
                HtmlToolBarGroup htmlToolBarGroup = new HtmlToolBarGroup();

                HtmlPanelMenu htmlPanelMenu = new HtmlPanelMenu();
                htmlPanelMenu.setStyle("width:200px");
                htmlPanelMenu.setMode("ajax");
                htmlPanelMenu.setIconExpandedGroup("disc");
                htmlPanelMenu.setIconCollapsedGroup("disc");
                htmlPanelMenu.setIconExpandedTopGroup("chevronUp");
                htmlPanelMenu.setIconGroupTopPosition("right");
                htmlPanelMenu.setIconCollapsedTopGroup("chevronDown");
                htmlPanelMenu.setId("menu1");
                HtmlPanelMenuGroup htmlPanelMenuGroup = new HtmlPanelMenuGroup();
                htmlPanelMenuGroup.setLabel("menugroup1");
                htmlPanelMenuGroup.setId("menugroup1");

                HtmlPanelMenuItem htmlPanelMenuItem = new HtmlPanelMenuItem();
                htmlPanelMenuItem.setLabel("item1");
                htmlPanelMenuItem.setId("menu1item1");

                htmlToolBarGroup.getChildren().add(htmlPanelMenu);

                htmlPanelMenu.getChildren().add(htmlPanelMenuGroup);
                htmlPanelMenuGroup.getChildren().add(htmlPanelMenuItem);

                return htmlToolBarGroup;
                }