4 Replies Latest reply on Oct 5, 2009 1:43 AM by jsfgeeks

    want to get the row key from the extendedDataTable.

    jsfgeeks

      Hi all,

      I am a newbie to the richfaces. I have an extendedDataTable to show and select some data from the database and to add to the other table. I am using calendar and checkbox inside the extendedDataTable. Now, what I want is that, if anyone changes the date or select the checkbox then I am calling the function of backbean like;

      <rich:column width="150px" style="text-align: center" label="Last Date">
       <f:facet name="header">
       <h:outputText value="Last Date"/>
       </f:facet>
       <rich:calendar immediate="false" cellHeight="7" cellWidth="20" boundaryDatesMode="scroll" showWeeksBar="false" showHeader="false" inputSize="12" datePattern="dd/MM/yyyy" showFooter="false" jointPoint="top-right" direction="top-left" popup="true">
       <a4j:support immediate="true" action="#{backbean.method_of_backbean}"
       event="onchanged"/>
       </rich:calendar>
       </rich:column>


      It's working fine (I mean it calls the backbean method). But I don't know how to get the row key and that changed value.

      Any help regarding this will help me a lot.

      Thanks in advance
      Jsf Geeks

        • 1. Re: want to get the row key from the extendedDataTable.
          ilya_shaikovsky

          http://livedemo.exadel.com/richfaces-demo/richfaces/dataTable.jsf?tab=editDataTable not fully the same as you need but idea of getting current row implemented,

          • 2. Re: want to get the row key from the extendedDataTable.
            jsfgeeks

            Hi ilya_shaikovsky,

            Thanks for your support. I have seen there, but as I told you I want a backbean code which can help me to get the data of that particular row. Actually I am trying but right now I just can get the row key.

            If there is any other way available, then also you can tell me. And if possible, give me a sample code, so that I can better understand.

            Thanks again,
            Jsf Geeks

            • 3. Re: want to get the row key from the extendedDataTable.
              ilya_shaikovsky

              visit a link in my signature. at the page you will find the link to full SVN sources

              • 4. Re: want to get the row key from the extendedDataTable.
                jsfgeeks

                Hi ilya_shaikovsky,

                I again appreciate your help. I have seen there, but as a newbie, I am not able to get the thing. So now I am showing my code for the table. I mean what I have done till now.

                The table(JSP):

                <rich:extendedDataTable binding="#{assign_car.table_car_list}" value="#{assign_car.car_list}" var="row" id="table_car_list" style="left: 15px; top: 65px; position: absolute" onRowMouseOver="this.style.backgroundColor='#F1F1F1'" onRowMouseOut="this.style.backgroundColor='#FFFFFF'" width="650px" height="208px" sortMode="Ascending" rows="0">
                 <f:facet name="header">
                 <h:outputText value="Assign Car"/>
                 </f:facet>
                
                <rich:column id="car_sel" width="190px" style="text-align: center" label="Select Car">
                 <f:facet name="header">
                 <h:outputText value="Select Car" />
                 </f:facet>
                <h:selectBooleanCheckbox binding="#{assign_car.cb_select_car}" immediate="false" id="cb_select_topic">
                 <a4j:support event="onchange" immediate="true" action="#{assign_car.value_change_car_selection_cb}">
                 </a4j:support>
                 </h:selectBooleanCheckbox>
                </rich:column>
                 <rich:column id="car_name" sortBy="#{row.car}" width="220px" label="Topic">
                 <f:facet name="header">
                 <h:outputText value="Car Name" />
                 </f:facet>
                 <h:outputText id="col_car_name" value="#{row.car}"/>
                 </rich:column>
                </rich:extendedDataTable>
                 <a4j:commandButton id="btn_add_cars" action="#{assign_car.action_add_cars}" style="width: 70px; left: 15px; top: 282px; position: absolute" value="Add"/>
                


                Backbean:
                ArrayList<newlist> car_list = new ArrayList<newlist>(); //with it's getter and setter
                public class newlist{
                 String c_name;
                public newlist(String name_of_car){
                 this.c_name=name_of_car;
                }
                 public String getC_name() {
                 return c_name;
                 }
                }
                
                // function from which I add cars to list
                car_list.add(new newlist(rs.getString("car_name")));
                
                
                // value change event
                public String value_change_car_selection_cb()
                {
                try
                 {
                 System.out.println("\n\t Test Selection made to : "+cb_select_car.getSubmittedValue());
                 System.out.println("\n\t Row key on which the car is checked or unchecked : "+table_car_list.getActiveRowKey());
                 }
                 catch(Exception e)
                 {
                 System.out.println("Error in fetching selected cars...\n\t "+e);
                 }
                }
                
                // action event of add button
                public String action_add_cars()
                 {
                 try
                 {
                 // I don't have anything to write here
                 }
                 catch(Exception e)
                 {
                 System.out.println("Error in assigning cars...\n\t "+e);
                 }
                 return null;
                 }
                


                So, now if you can help me then its great for me.

                Thanks for your support,
                JSF GEEKS