4 Replies Latest reply on Nov 2, 2011 4:24 AM by Christian Peter

    a4j:commandLink not working with binding component

    adb_soft Newbie

      I have a project to create a menu dynamically from the database. the menu is created dynamically in bakingBean with a composition of h: panelGroup and UICommandLink.
      But the method associated with the action of the a4j: commandLink does not run, and what is strange is that the phase
      INVOKE_APPLICATION is completed without error !!

      Can someone help me to solve this problem.??

      thinks a lot


        • 1. Re: a4j:commandLink not working with binding component
          Christian Peter Expert

          Which RF version do you use? I have RF 3.3.4-snapshot and I do almost the same. A dynamic menu from database (EJB entities).

           

          A h:panelgroup serves as a container for UL, LI, SPAN an h:commandLink or a4j:commandLink Components. I'm using h:commandLinks now because we do not need ajax here to navigate. (There is an "onbeforeunload" listener on the page. Ajax'll get broken if the user wants to stay on page)

           

          Sorry, but I don't have the sourcescodes right here available. But I created MethodExpressions / ActionExpressions for each Link, which are EL expressions build from Strings.

          • 2. Re: a4j:commandLink not working with binding component
            adb_soft Newbie

            Thank you for your explanation.

            I use RF 4 and JSF 2 and I proceed with the same way.

            they attached the source code of my Method :

             

            // create the panelGroup

            HtmlPanelGroup grp= new HtmlPanelGroup();

            grp.setId("GR"+menu.getId());

            // create CommandLink

            UICommandLink link = UIComponentUtils.createA4JLink();

            link.setValue(menu.getNom());

            link.setId("idmenuItem_"+menu.getId ());

            // add param to CommandLink

            UIParameter paramParam = new UIParameter();

            paramParam.setValue(menu.getParam());

            paramParam.setName(PARAM);

            // add Action to link

            MethodExpression methodExpression = UIComponentUtils.createAction("#{myPageBean.navigate}", String.class);

            link.setActionExpression(methodExpression);

            // add link to the container grp

            grp.getChildren().add(link);

             

            and I call the component in my page as

            <h:panelGroup id="menus"  binding="#{myPageBean.liste}"/>

             

            I also noticed that without the ID every component does not work !!

            I hope someone can explain the correct approach in this case

            • 3. Re: a4j:commandLink not working with binding component
              adb_soft Newbie

              I have finally found the problem, As I have already noted

               

              I also noticed that without the ID every component does not work !!

               

              I had an " _ " in the client id of the component

              Someone understood something?

              • 4. Re: a4j:commandLink not working with binding component
                Christian Peter Expert

                I had problems with the underscore in Ids, too. I think it's an illegal character.