1 2 Previous Next 15 Replies Latest reply on Mar 22, 2010 5:50 AM by ilya_shaikovsky

    Use richfaces datatable inside PanelMenuItem

    sincanvin

      Hi,

       

        I am new to Richfaces and trying to use datatable inside panelmenuitem. I want to get the datatable loaded using AJAX on the expansion of menuitem but not able to do so. Right now bean is getting loaded with the page and I want to get this loaded only when the menu item is expanded.

       

      Pl. tell me how to get this done. I tried calling bean in Action of PanelMenuItem but not able to render the datatable.

       

      Pl. guide me do this.

       

      Thanks,

      Vinny

        • 1. Re: Use richfaces datatable inside PanelMenuItem
          sincanvin

          I am trying to render the datatable on action but get the exception. I want to make AJAX call to load the data from server only when the menuitem is expanded.

           

           

          <rich:panelMenuGroup style="none" label="#{app.appName}" expandMode="ajax">
                                                              <rich:panelMenuItem icon="none" rendered="ext" mode="ajax" onclick="true" action="#{rolesBean.dataList}">
                                                                  <rich:datatable
                                                                      id="ext"
                                                                      value="#{rolesBean.list}"                                                                      
                                                                                  var="dataItem"
                                                                                  rowClasses="dataTableOddRow, dataTableEvenRow" rows="4"
                                                                                  reRender="datascroller1"
                                                                                  columnClasses="50,100,100,100"
                                                                                  onRowMouseOver="this.style.backgroundColor='#B5F3FB'"
                                                                                  onRowMouseOut="this.style.backgroundColor='#{a4jSkin.rowBackgroundColor}'"
                                                                                  width="350">

           

           

           

          exception

          javax.servlet.ServletException: duplicate Id for a component j_id3:ext
               javax.faces.webapp.FacesServlet.service(FacesServlet.java:277)
               org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
               org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
               org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
               org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
               org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
          
          • 2. Re: Use richfaces datatable inside PanelMenuItem
            ilya_shaikovsky
            moving the thread to just RichFaces space from development-specific RF development.
            • 3. Re: Use richfaces datatable inside PanelMenuItem
              ilya_shaikovsky

              if you need to fill the table on expansion of the group use action or listener of menu group instead of action of item itself. It's executed afetr item click. Also change mode of the item to none as I do not sure if the click on the table should be processed with item as just menu activation. Also check please rendered and onclick declaration. Them contains senseless values. It's standard attibutes and: rendered - boolean attribute which defines if the componetn should be rendered and on* attributes - client events handlers.

               

              As about exception - check some other components with the same id and make sure that you not using session scoped bindings.

              • 4. Re: Use richfaces datatable inside PanelMenuItem
                sincanvin

                I tried doing the following but getting NULL object. Is this the way you said

                 

                 

                <rich:panelMenuGroup rendered="true" label="Applications" actionListener="#{rolesBean.loadData}" reRender="roles">
                                          <rich:panelMenuItem icon="none" id="pitem" >
                                                        <rich:dataTable value="#{rolesBean.list}"  <-- Calls the list object from bean
                                                                                            id="roles"
                                                                                            var="dataItem"
                                                                                            reRender="datascroller1"
                                                                                            rowClasses="dataTableOddRow, dataTableEvenRow" rows="4"
                                                                                            columnClasses="50,100,100,100"
                                                                                            onRowMouseOver="this.style.backgroundColor='#B5F3FB'"
                                                                                            onRowMouseOut="this.style.backgroundColor='#{a4jSkin.rowBackgroundColor}'"
                                                                                            width="350">

                 

                 

                 

                public void loadData (ActionEvent event) {

                             loadRoleseList(); // This method builds the object with values.
                }

                 

                Pl. help.

                • 5. Re: Use richfaces datatable inside PanelMenuItem
                  ilya_shaikovsky
                  add reRender defined with dataTable id to the group.
                  • 6. Re: Use richfaces datatable inside PanelMenuItem
                    sincanvin

                    it is already there in the panelMenuGroup

                     

                    <rich:panelMenuGroup rendered="true" label="Applications" actionListener="#{rolesBean.loadData}" reRender="roles">

                     

                     

                    Do I need to define any event like onclick for actionListener or any other even.. I even tried using onclick="true" but getting NULL object.. infact, bean's method in the actionListener is not getting invoked.

                    • 7. Re: Use richfaces datatable inside PanelMenuItem
                      harut

                      t.. infact, bean's method in the actionListener is not getting invoked.

                      Can you post actionListener method ?

                      • 8. Re: Use richfaces datatable inside PanelMenuItem
                        harut
                        sorry.. I see... you have posted it in your previous post...
                        • 9. Re: Use richfaces datatable inside PanelMenuItem
                          harut

                          sincanvin wrote:

                           

                          it is already there in the panelMenuGroup

                           

                          <rich:panelMenuGroup rendered="true" label="Applications" actionListener="#{rolesBean.loadData}" reRender="roles">

                           

                           

                          Do I need to define any event like onclick for actionListener or any other even.. I even tried using onclick="true" but getting NULL object.. infact, bean's method in the actionListener is not getting invoked.

                          The code seems correct.. no "onclick" is needed...

                           

                          What is the scope of the bean class rolesBean ?

                          • 10. Re: Use richfaces datatable inside PanelMenuItem
                            sincanvin

                            The bean is in request scope. In my bean I have a method called public void loadRoleseList() {}. This builds list of roles. I have


                            //Action Event method which calls Roles List method and this is called in actionListener for PanelMenuGroup
                            public void loadData (ActionEvent event) {
                             
                              loadRoleseList();
                                }


                            //This is returning List of roles. I am calling this in Datatable.  
                            public List <RolesData> getList()

                              return rolesList;
                            }


                            I want to build the object using actionListener of PanelMenuGroup and get the object in datatable.

                             

                            But loadData() is not getting called from actionListener() and when getList() is called in dataTable it returns NULL because the object is not yet constructed.  I am wondering why actionListener is not able to invoke loadData()

                             

                            Do you see any issues with the loadData method for actionListener.

                             

                            Thanks

                            • 11. Re: Use richfaces datatable inside PanelMenuItem
                              nbelaevski

                              Hi,

                               

                              You have removed expandMode="ajax", so panel menu group is operating solely on the client. That's the reason "actionListener" is not being called.

                              • 12. Re: Use richfaces datatable inside PanelMenuItem
                                sincanvin

                                Now I am able to get the actionListener invoked but only after a click on the header dataTable and then the data gets loaded.

                                 

                                                     <rich:panelMenuGroup label="Roles defined" expandMode="ajax">
                                                            <rich:panelMenuItem icon="none" rendered="true" reRender="Roles" actionListener="#{rolesBean.onAction}">
                                                                                       <rich:dataTable value="#{rolesBean.list}"
                                                                                                            id="Roles"
                                                                                                            var="dataItem"
                                                                                                            reRender="datascroller1"
                                                                                                            rowClasses="dataTableOddRow, dataTableEvenRow" rows="4"
                                                                                                            columnClasses="50,100,100,100"
                                                                                                            onRowMouseOver="this.style.backgroundColor='#B5F3FB'"
                                                                                                            onRowMouseOut="this.style.backgroundColor='#{a4jSkin.rowBackgroundColor}'"
                                                                                                            width="350">

                                 

                                 

                                Inititally, after expanding the PanelMenuItem dataTable gets loaded without any data but after clicking on the header of DataTable I see the action method getting invoked and data getting loaded.

                                 

                                Can you tell why is this happening.. ActionListener should be fired on the click of Menu item...

                                 

                                Pl. guide

                                • 13. Re: Use richfaces datatable inside PanelMenuItem
                                  harut

                                  Set ActionListener and reRender to menuGroup not to it's item:

                                   

                                  <rich:panelMenuGroup label="Roles defined" expandMode="ajax" actionListener="#{rolesBean.onAction}" reRender="Roles">

                                  • 14. Re: Use richfaces datatable inside PanelMenuItem
                                    sincanvin

                                    Thank you so much for your help. It worked this time with panel menu group.

                                     

                                    I have another query I am trying to iterate using <c:forEach> to populate <rich:panelMenuGroup>. I need to get the ID for DataTable changed with each iteration to avoid exception for duplicate ID.

                                     

                                     

                                     

                                    <c:forEach var="app" items="#{applicationBean.dataList}">
                                              <rich:panelMenuGroup  label="#{app.appName}">
                                                        <rich:panelMenuGroup label="Roles">
                                                                  <rich:panelMenuItem icon="none">
                                                                             <rich:dataTable value="#{rolesBean.dataList}"

                                                                               var="dataItem"

                                                                               id="??" 

                                     

                                     

                                    How can I do this?

                                    1 2 Previous Next