1 2 Previous Next 15 Replies Latest reply on Jun 5, 2009 9:01 AM by nbelaevski

    How to get the selected row of Data tabel to Managed bean

      I had a situation in which i need to get the double clicked row to be collected in the managed bean action method for that i had folwwing code in my data tabel tags like thius

       <a4j:support event="onRowDblClick" reRender="table" action="#{courseListBean.nominateToTheCourse}" />
       </rich:extendedDataTable>
      


      i need the doubled clciked row to be collected in my nominateToTheCourse methdo how can i do that...?

      thanks in advance..


        • 1. Re: How to get the selected row of Data tabel to Managed bea

          could any body help me on thsi please...

          i cant even see the action method mentioned in the a4j:support triggering.

          • 2. Re: How to get the selected row of Data tabel to Managed bea
            nbelaevski

            Hi,

            Add rich:messages to the page and check if any were generated.

            • 3. Re: How to get the selected row of Data tabel to Managed bea

              Thanks for your reply i added that as well and cheked but i cant see any messages..

              • 4. Re: How to get the selected row of Data tabel to Managed bea
                nbelaevski

                Does request fire at all? Add a4j:status to check.

                • 5. Re: How to get the selected row of Data tabel to Managed bea

                  i tried seeing the method call using debug mode but icant see the method getting called.

                  • 6. Re: How to get the selected row of Data tabel to Managed bea
                    nbelaevski

                     

                    "shivaji.byrapaneni" wrote:
                    i tried seeing the method call using debug mode but icant see the method getting called.

                    I see. Add a4j:status and check request presence.

                    • 7. Re: How to get the selected row of Data tabel to Managed bea
                      ilya_shaikovsky

                       

                      <h:form>
                       <h:panelGrid columns="2" columnClasses="top,top">
                       <rich:extendedDataTable value="#{extendedTableBean.capitalsDataModel}" var="cap" id="table"
                       width="580px" height="150px">
                       <rich:column sortable="false" label="Flag">
                       <f:facet name="header">
                       <h:outputText value="Flag"/>
                       </f:facet>
                       <h:graphicImage value="#{cap.stateFlag}"/>
                       </rich:column>
                       <rich:column label="State Name">
                       <f:facet name="header">
                       <h:outputText value="State Name"/>
                       </f:facet>
                       <h:outputText value="#{cap.state}"/>
                       </rich:column>
                       <rich:column label="State Capital">
                       <f:facet name="header">
                       <h:outputText value="State Capital"/>
                       </f:facet>
                       <h:outputText value="#{cap.name}"/>
                       </rich:column>
                       <rich:column label="Time Zone">
                       <f:facet name="header">
                       <h:outputText value="Time Zone"/>
                       </f:facet>
                       <h:outputText value="#{cap.timeZone}"/>
                       </rich:column>
                       <a4j:support event="onRowClick" action="#{extendedTableBean.action}">
                       <f:setPropertyActionListener value="#{cap}" target="#{extendedTableBean.selectedCapital}" />
                       </a4j:support>
                       </rich:extendedDataTable>
                       </h:panelGrid>
                       </h:form>


                      and
                      public class ExtendedTableBean {
                       private String sortMode="single";
                       private String selectionMode="multi";
                      
                       private ExtendedTableDataModel<Capital> dataModel;
                       private List<Capital> capitals = new ArrayList<Capital>();
                      
                       private Capital selectedCapital;
                       public void action() {
                       System.out.println(selectedCapital.getName());
                       }
                      
                       public Capital getSelectedCapital() {
                       return selectedCapital;
                       }
                      
                       public void setSelectedCapital(Capital selectedCapital) {
                       this.selectedCapital = selectedCapital;
                       }
                      


                      and after clicking the row there are clicked capital name in the console.


                      • 8. Re: How to get the selected row of Data tabel to Managed bea

                        Thanks a lot for your replay

                        but i too tried teh same but that idnt work
                        im posting here my jsp and mbean . please correct me if i did any thing absured

                        <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
                        <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
                        <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
                        <!-- RichFaces tag library declaration -->
                        <%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
                        <%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
                        <h:form>
                         <h:panelGrid columns="2" columnClasses="top,top">
                         <rich:messages />
                         <rich:extendedDataTable value="#{courseListBean.coursesList}"
                         id="courseListEDT" binding="#{courseListBean.courseListEDT}"
                         var="course" width="700px" height="400px" sortMode="single"
                         selectionMode="single">
                         <rich:column sortable="false" label="Course Image" width="40px"
                         id="imageColumn" binding="#{courseListBean.imageColumn}">
                         <f:facet name="header">
                         <h:outputText value="" />
                         </f:facet>
                         <h:graphicImage value="/Images/create_doc.gif" />
                         </rich:column>
                         <rich:column sortable="true" sortBy="#{course.courseName}"
                         filterBy="#{course.courseName}" filterEvent="onkeyup" width="170px"
                         label="Course Name" id="courseNameColumn"
                         binding="#{courseListBean.courseNameColumn}">
                         <f:facet name="header">
                         <h:outputText value="Course Name" />
                         </f:facet>
                         <h:outputText value="#{course.courseName}" />
                         </rich:column>
                         <rich:column sortable="true" sortBy="#{course.noOfSeats}"
                         filterBy="#{course.noOfSeats}" filterEvent="onkeyup" width="170px"
                         label="No Of Seats" id="noOfSeatsColumn"
                         binding="#{courseListBean.noOfSeatsColumn}">
                         <f:facet name="header">
                         <h:outputText value="no Of Seats" />
                         </f:facet>
                         <h:outputText value="#{course.noOfSeats}" />
                         </rich:column>
                         <rich:column sortable="false" label="on Date" id="onDateColumn"
                         binding="#{courseListBean.onDateColumn}">
                         <f:facet name="header">
                         <h:outputText value="on Date" />
                         </f:facet>
                         <h:outputText value="#{course.onDate}" />
                         </rich:column>
                        
                         <rich:column sortable="false" label="Time" id="timeColumn"
                         binding="#{courseListBean.timeColumn}">
                         <f:facet name="header">
                         <h:outputText value="Time" />
                         </f:facet>
                         <h:outputText value="#{course.courseTime}" />
                         </rich:column>
                        
                         <rich:column sortable="false" label="location" id="locationColumn"
                         binding="#{courseListBean.locationColumn}">
                         <f:facet name="header">
                         <h:outputText value="location" />
                         </f:facet>
                         <h:outputText value="#{course.location}" />
                         </rich:column>
                         <a4j:support event="onRowDblClick" reRender="table"
                         actionListener="#{courseListBean.nominateToTheCourse}">
                         <f:setPropertyActionListener value="#{course}"
                         target="#{courseListBean.currentRow}" />
                         </a4j:support>
                         </rich:extendedDataTable>
                         </h:panelGrid>
                        </h:form>
                        
                        


                        and my mbean is this

                        
                        package com.managedbeans;
                        
                        import java.util.ArrayList;
                        
                        import javax.ejb.EJB;
                        import javax.faces.event.ActionEvent;
                        
                        import org.richfaces.component.html.HtmlColumn;
                        import org.richfaces.component.html.HtmlExtendedDataTable;
                        
                        import com.constants.NominationConstants;
                        import com.entities.CourseDetailsEO;
                        import com.logger.NominationLogger;
                        import com.services.local.CoursesInformationServiceLocal;
                        
                        public class CourseListBean extends NominationBaseBean {
                         private final String className = this.getClass().toString();
                         @EJB(mappedName = NominationConstants.COURSEINFOSERVICE_LOCAL)
                         private CoursesInformationServiceLocal coursesInformationService;
                         private ArrayList<CourseDetailsEO> coursesList = new ArrayList<CourseDetailsEO>();
                         private CourseDetailsEO currentRow ;
                         private HtmlExtendedDataTable courseListEDT;
                         private HtmlColumn imageColumn;
                         private HtmlColumn courseNameColumn;
                         private HtmlColumn noOfSeatsColumn;
                         private HtmlColumn onDateColumn;
                         private HtmlColumn timeColumn;
                        
                         public CourseDetailsEO getCurrentRow() {
                         return currentRow;
                         }
                        
                         public void setCurrentRow(CourseDetailsEO currentRow) {
                         this.currentRow = currentRow;
                         }
                        
                         public HtmlExtendedDataTable getCourseListEDT() {
                         return courseListEDT;
                         }
                        
                         public void setCourseListEDT(HtmlExtendedDataTable courseListEDT) {
                         this.courseListEDT = courseListEDT;
                         }
                        
                         public HtmlColumn getImageColumn() {
                         return imageColumn;
                         }
                        
                         public void setImageColumn(HtmlColumn imageColumn) {
                         this.imageColumn = imageColumn;
                         }
                        
                         public HtmlColumn getCourseNameColumn() {
                         return courseNameColumn;
                         }
                        
                         public void setCourseNameColumn(HtmlColumn courseNameColumn) {
                         this.courseNameColumn = courseNameColumn;
                         }
                        
                         public HtmlColumn getNoOfSeatsColumn() {
                         return noOfSeatsColumn;
                         }
                        
                         public void setNoOfSeatsColumn(HtmlColumn noOfSeatsColumn) {
                         this.noOfSeatsColumn = noOfSeatsColumn;
                         }
                        
                         public HtmlColumn getOnDateColumn() {
                         return onDateColumn;
                         }
                        
                         public void setOnDateColumn(HtmlColumn onDateColumn) {
                         this.onDateColumn = onDateColumn;
                         }
                        
                         public HtmlColumn getTimeColumn() {
                         return timeColumn;
                         }
                        
                         public void setTimeColumn(HtmlColumn timeColumn) {
                         this.timeColumn = timeColumn;
                         }
                        
                         public HtmlColumn getLocationColumn() {
                         return locationColumn;
                         }
                        
                         public void setLocationColumn(HtmlColumn locationColumn) {
                         this.locationColumn = locationColumn;
                         }
                        
                         private HtmlColumn locationColumn;
                        
                         public ArrayList<CourseDetailsEO> getCoursesList() {
                         return coursesList;
                         }
                        
                         public void setCoursesList(ArrayList<CourseDetailsEO> coursesList) {
                         this.coursesList = coursesList;
                         }
                        
                         public void loadCourseList() {
                         final String methodName = "loadCourseList";
                         NominationLogger.logMethodEntry(className, methodName);
                         coursesList = coursesInformationService.getCourseInfo();
                         NominationLogger.logMethodExit(className, methodName);
                         //return NominationConstants.NominationHome;
                         }
                        
                         public String nominateToTheCourse(ActionEvent event){
                         final String methodName = "nominateToTheCourse";
                         NominationLogger.logMethodEntry(className, methodName);
                        
                         NominationLogger.logMethodExit(className, methodName);
                         return null;
                         }
                        
                        }
                        
                        


                        please help me in sorting out this issue.

                        Many Thanks in advance.

                        • 9. Re: How to get the selected row of Data tabel to Managed bea
                          nbelaevski

                          Well, what does a4j:status show?

                          • 10. Re: How to get the selected row of Data tabel to Managed bea
                            ilya_shaikovsky

                            I wanted you not to tried "almost the same" but explore the code listed and looked for problems in your code :)

                            which scope of your bean.

                            • 11. Re: How to get the selected row of Data tabel to Managed bea

                              im not aware of that tag. Any way i checked with debug and cant see teh method getting called

                              • 12. Re: How to get the selected row of Data tabel to Managed bea

                                i had most of my questions answered in the demo site provided.
                                so, i m just trying to mix them up to make my application.

                                My managed bean is in request scope.

                                • 13. Re: How to get the selected row of Data tabel to Managed bea
                                  nbelaevski

                                  Ok, can you debug the reason why it's not being called? Start with UIViewRoot methods.

                                  • 14. Re: How to get the selected row of Data tabel to Managed bea

                                    im afraid to say that im not that master in using richfaces

                                    could please hlep me by telling how it should be done...?

                                    1 2 Previous Next