10 Replies Latest reply on Apr 3, 2009 6:02 AM by Waqas Arshad

    Unable to pick the selected row from Datatable

    Waqas Arshad Novice

      I've a list which update datatable using ajax. Now my requirement is to pick the clicked row from the datatable. Everything is working fine but when i click the link it do nothing.


      <h:selectOneMenu id="tsheet" styleClass="text_body">
       <f:selectItem id="o1" itemLabel="Regular" itemValue="reg" />
       <f:selectItem id="o2" itemLabel="Supplement" itemValue="supp" />
       <a4j:support event="onchange" reRender="reg_table" action = "#{Test.getRegular}" />
      <h:dataTable id="reg_table" value="#{Test.beanList}" var="reg" binding="#{Test.dataTable}" border="1" >
       <f:facet name="header">
       <h:outputText value="REGULAR TIMESHHET" />
       <h:column >
       <f:facet name="header" >
       <h:outputText value="Status" />
       <h:commandLink id="taskName" value="Approve">
       <a4j:support event="onclick" action="#{Test.getCurrentRow}"></a4j:support>
       <h:column >
       <f:facet name="header" >
       <h:outputText value="Name" />
       <h:outputText value="#{reg.name}" />
       <f:facet name="header" >
       <h:outputText value="Age" />
       <h:outputText value="#{reg.age}" />

      public class Test {
       private List<MyBean> beanList = new ArrayList<MyBean>();;
       private HtmlDataTable dataTable;
       private MyBean dataItem = new MyBean();
      ...setter, getter
      public void getRegular() {
       beanList = new ArrayList<MyBean>();
       beanList.add(new MyBean("New1", "11", "1"));
       beanList.add(new MyBean("New2", "22", "2"));
       beanList.add(new MyBean("New3", "33", "3"));
      public void getCurrentRow()
       MyBean objMyBean = (MyBean) dataTable.getRowData();
       System.out.println("Name : -" +objMyBean.getName());
       System.out.println("Class : -" +objMyBean.getAge());

      Any suggestions.