13 Replies Latest reply on May 21, 2009 6:45 PM by Mehdi BRAHMIA

    Is this possible? rich:panelMenuItem in a4j:repeat

    chamika deshan Newbie

      Hi all
      I'm trying to repeat rich:panelMenuItems using a4j:repeat.
      This is my code

      <rich:panelMenu>
       <rich:panelMenuGroup label="Roles">
       <a4j:repeat value="#{ApplicationBean1.roles}" var="item">
       <rich:panelMenuItem label="#{item.description}" >
       <f:param name="current" value="#{item.description}"/>
       </rich:panelMenuItem>
       </a4j:repeat>
       </rich:panelMenuGroup>
       </rich:panelMenu>
      


      When run it there is an error saying
      java.lang.ClassCastException: org.ajax4jsf.component.html.HtmlAjaxRepeat

      But when I put it like below(put a4j:repeat outside) it works, but instead of generating panelMenuItem it repeats panelMenus. How do I solve this problem. Plase help me.

      <a4j:repeat value="#{ApplicationBean1.roles}" var="item">
       <rich:panelMenu>
       <rich:panelMenuGroup label="Roles">
       <rich:panelMenuItem label="#{item.description}" >
       <f:param name="current" value="#{item.description}"/>
       </rich:panelMenuItem>
       </rich:panelMenuGroup>
       </rich:panelMenu>
       </a4j:repeat>
      


        • 1. Re: Is this possible? rich:panelMenuItem in a4j:repeat
          Sergey Smirnov Master

          a4j:repeat component is not in the list if valid children for panelMenuGroup. Use c:forEach or create menu from the Java code

          • 2. Thanks
            chamika deshan Newbie

             

            "SergeySmirnov" wrote:
            a4j:repeat component is not in the list if valid children for panelMenuGroup. Use c:forEach or create menu from the Java code


            SergeySmirnov

            Thank u very much for ur reply. My problem solved by you.
            This is the working code

            <jsp:root version="2.1" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:webuijsf="http://www.sun.com/webui/webuijsf"
             xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich">
             <jsp:directive.page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"/>
             <f:view>
             <webuijsf:page id="page1">
             <webuijsf:html id="html1">
             <webuijsf:head id="head1">
             <webuijsf:link id="link1" url="/resources/stylesheet.css"/>
             </webuijsf:head>
             <webuijsf:body id="body1" style="-rave-layout: grid">
             <webuijsf:form id="form1">
             <rich:panelMenu groupStyle="z-index:3000;" iconCollapsedGroup="disc" iconCollapsedTopGroup="chevronDown" iconExpandedGroup="disc"
             iconExpandedTopGroup="chevronUp" iconGroupTopPosition="right" mode="ajax" style="width:300px">
             <rich:panelMenuGroup label="User Roles">
             <c:forEach var="urole" items="#{ApplicationBean1.roles}" >
             <rich:panelMenuItem label="#{urole.description}">
             <f:param name="current" value="#{urole.code}" />
             </rich:panelMenuItem>
             </c:forEach>
             </rich:panelMenuGroup>
             </rich:panelMenu>
             </webuijsf:form>
             </webuijsf:body>
             </webuijsf:html>
             </webuijsf:page>
             </f:view>
            </jsp:root>
            


            Thanx again

            • 3. Re: Is this possible? rich:panelMenuItem in a4j:repeat
              traysa b Newbie

              hiya,

              I try to build a dynamic panelMenu. I don't want to bind the whole panelMenu in a backing bean, because I have to do some rerendering during the apllication is running.
              So I also build an iterative panelMenu with <c:forEach>. But somehow it doesn't work.
              Here's the code

              <rich:panelMenu width="200px" mode="ajax"
               iconExpandedGroup="disc" iconCollapsedGroup="disc"
               iconExpandedTopGroup="chevronUp" iconGroupTopPosition="right"
               iconCollapsedTopGroup="chevronDown">
               <rich:panelMenuGroup label="test">
               <c:forEach items="#{menuGroup.menuItems}" var="item">
               <rich:panelMenuItem label="#{item.title}" action="#{item.url}"/>
               </c:forEach>
               </rich:panelMenuGroup>
              </rich:panelMenu>
              


              I only get the panelMenuGroup with the label 'test', but there are no items in the panelMenuGroup. the list menuItems is not empty. Is it right, that the c:forEach doesn't use setters and getters?
              Can somebody give me any suggestions?

              thx,
              traysa

              • 4. Re: Is this possible? rich:panelMenuItem in a4j:repeat
                chamika deshan Newbie

                I'm not much sure about the solution. But try to change "menuGroup" beans scope to session and make sure the "menuItems" getters and setters are correctly set.

                • 5. Re: Is this possible? rich:panelMenuItem in a4j:repeat
                  Nick Belaevski Master

                   

                  "traysa" wrote:
                  hiya,

                  I try to build a dynamic panelMenu. I don't want to bind the whole panelMenu in a backing bean, because I have to do some rerendering during the apllication is running.
                  So I also build an iterative panelMenu with <c:forEach>. But somehow it doesn't work.
                  Here's the code

                  <rich:panelMenu width="200px" mode="ajax"
                   iconExpandedGroup="disc" iconCollapsedGroup="disc"
                   iconExpandedTopGroup="chevronUp" iconGroupTopPosition="right"
                   iconCollapsedTopGroup="chevronDown">
                   <rich:panelMenuGroup label="test">
                   <c:forEach items="#{menuGroup.menuItems}" var="item">
                   <rich:panelMenuItem label="#{item.title}" action="#{item.url}"/>
                   </c:forEach>
                   </rich:panelMenuGroup>
                  </rich:panelMenu>
                  


                  I only get the panelMenuGroup with the label 'test', but there are no items in the panelMenuGroup. the list menuItems is not empty. Is it right, that the c:forEach doesn't use setters and getters?
                  Can somebody give me any suggestions?

                  thx,
                  traysa


                  Do you use Facelets or JSP? What is URI for c:* prefix?

                  • 6. Re: Is this possible? rich:panelMenuItem in a4j:repeat
                    Chen Chuhao Newbie

                     

                    "traysa" wrote:
                    hiya,

                    I try to build a dynamic panelMenu. I don't want to bind the whole panelMenu in a backing bean, because I have to do some rerendering during the apllication is running.
                    So I also build an iterative panelMenu with <c:forEach>. But somehow it doesn't work.
                    Here's the code

                    <rich:panelMenu width="200px" mode="ajax"
                     iconExpandedGroup="disc" iconCollapsedGroup="disc"
                     iconExpandedTopGroup="chevronUp" iconGroupTopPosition="right"
                     iconCollapsedTopGroup="chevronDown">
                     <rich:panelMenuGroup label="test">
                     <c:forEach items="#{menuGroup.menuItems}" var="item">
                     <rich:panelMenuItem label="#{item.title}" action="#{item.url}"/>
                     </c:forEach>
                     </rich:panelMenuGroup>
                    </rich:panelMenu>
                    


                    I only get the panelMenuGroup with the label 'test', but there are no items in the panelMenuGroup. the list menuItems is not empty. Is it right, that the c:forEach doesn't use setters and getters?
                    Can somebody give me any suggestions?

                    thx,
                    traysa


                    Same problem in RF-3.1.4, upgrade to RF-3.2.2 is okay.

                    • 7. Re: Is this possible? rich:panelMenuItem in a4j:repeat
                      traysa b Newbie

                      Thanks for the reply :)

                      @chamika: I tried your suggestion, but it take no effect.

                      @nbelaevski: I'm using JSP. The URI for c prefix is http://java.sun.com/jsp/jstl/core.

                      @realsantino: I'm using RF-3.2 and just updated to RF-3.3.


                      I changed

                      <c:forEach items="#{menuGroup.menuItems}" var="item">

                      to
                      <c:forEach items="${menuGroup.menuItems}" var="item">

                      Now I have the right number of menuGroups, but the label aren't printed
                      (<rich:panelMenuItem label="#{item.title}" .../>).

                      thx,
                      traysa

                      • 8. Re: Is this possible? rich:panelMenuItem in a4j:repeat
                        chamika deshan Newbie

                        Have u tried it with using value instead of label?
                        Because I have done the exact thing with using rich:menuItem and it has only the "value" attribute and rich:panelMenuItem also has the "value" attribute.

                        This is the code

                        <h:form>
                         <rich:toolBar>
                         <rich:dropDownMenu>
                         <f:facet name="label">
                         <h:panelGroup>
                         <h:graphicImage value="#{pageContext.request.contextPath}/resources/images/blinklist.png" styleClass="pic"/>
                         <h:outputText value="User Roles"/>
                         </h:panelGroup>
                         </f:facet>
                         <c:forEach var="urole" items="#{SessionDetails.user.roles}" >
                         <rich:menuItem submitMode="server" value="#{urole.description}" icon="#{pageContext.request.contextPath}/resources/images/vista_xp.gif"
                         action="#{MainPage.printPara}" >
                         <f:param name="sendUrl" value="#{urole.pageUrl}" />
                         </rich:menuItem>
                         </c:forEach>
                         </rich:dropDownMenu>
                         </rich:toolBar>
                        </h:form>
                        


                        • 9. Re: Is this possible? rich:panelMenuItem in a4j:repeat
                          traysa b Newbie

                          change of label to value has no effect :(
                          thx

                          • 10. Re: Is this possible? rich:panelMenuItem in a4j:repeat
                            Nick Belaevski Master

                            Traysa,

                            My suggestion why that is happening is that you are using JSP 2.0 version of JSTL and not JSP 2.1. Please check what JSP version is declared in c.tld file.

                            • 11. Re: Is this possible? rich:panelMenuItem in a4j:repeat
                              Mehdi BRAHMIA Newbie

                              Hello !

                              I got the same problem and I haven't found any solution.

                              About the JSP version of JSTL, Here is the begining of my c.tld

                              <taglib xmlns="http://java.sun.com/xml/ns/j2ee"
                               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                               xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
                               version="2.0">
                              
                               <description>JSTL 1.1 core library</description>
                               <display-name>JSTL core</display-name>
                               <tlib-version>1.1</tlib-version>
                               <short-name>c</short-name>
                               <uri>http://java.sun.com/jsp/jstl/core</uri>
                              


                              So this si the the JSP 2.0 version of JSTL ? Where can I find the the 2.1 and how to install it ?

                              Thanks a lot!

                              • 12. Re: Is this possible? rich:panelMenuItem in a4j:repeat
                                Nick Belaevski Master

                                Check appserv-jstl.jar in Glassfish distribution.

                                • 13. Re: Is this possible? rich:panelMenuItem in a4j:repeat
                                  Mehdi BRAHMIA Newbie

                                  I finally found the problem : the address in the statement was wrong :

                                  This is the right statement
                                  xmlns:c="http://java.sun.com/jstl/core"