Exception thrown while accessing HTML DataTable in backing bean

Posted by Denzil on Stack Overflow See other posts from Stack Overflow or by Denzil
Published on 2009-07-03T10:09:21Z Indexed on 2010/05/12 11:04 UTC
Read the original article Hit count: 331

Filed under:

Hi folks,

I am building a simple application in JSF with the CrUD functionality. I am trying to implement edit functionality using the tomahawk component .I am unable to retrieve the selected row in my backing bean.

Here's my JSP file snip:

       <t:dataTable id="data"
          binding="#{selectOneRowList.dataTable}"
            styleClass="scrollerTable"
            headerClass="standardTable_Header"
            footerClass="standardTable_Header"
            rowClasses="standardTable_Row1,standardTable_Row2"
            columnClasses="standardTable_Column,standardTable_ColumnCentered,standardTable_Column"
            var="car"
            value="#{selectOneRowList.list}"
            sortColumn="#{selectOneRowList.sortColumn}"
            sortAscending="#{selectOneRowList.sortAscending}"
            preserveDataModel="false"
            preserveSort="true"
            preserveRowStates="true"
            rows="10"
       >
       <h:column>
           <f:facet name="header">
               <h:outputText value="Select"/>
           </f:facet>
           <t:selectOneRow  groupName="selection" id="hugo" value="#{selectOneRowList.selectedRowIndex}"
                   onchange="submit();" immediate="true"
                   valueChangeListener="#{selectOneRowList.processRowSelection}"/>
       </h:column>

       <h:column>
           <f:facet name="header">
           </f:facet>
           <h:outputText value="#{car.id}" />
       </h:column>

       <h:column>
           <f:facet name="header">
              <h:outputText value="Cars" />
           </f:facet>
           <h:outputText value="#{car.type}" />
       </h:column>

       <t:column sortable="true">
           <f:facet name="header">
              <h:outputText value="Color" />
            </f:facet>
           <h:outputText value="#{car.color}" />
       </t:column>

    </t:dataTable>

Here's my backing bean SelectOneRowList.java :

     public void editCar(ActionEvent event) {
    System.out.println("Row number ## " + _selectedRowIndex.toString() + " selected!");
    System.out.println("Datatable ::"+ dataTable);    	    	
    System.out.println("Row Count ::" + dataTable.getRowCount());
    dataItem = (SimpleCar) getDataTable().getRowData();

    //selectedCar = (SimpleCar)  _list.get(Integer.parseInt(_selectedRowIndex.toString()));
    selectedCar = (SimpleCar) dataTable.getRowData();

    System.out.println(dataTable.getRowData());
}

My DTO{Data Transfer Object} which is SimpleCar.java contains the variables ID, type, color and their respective setters/getters.

The dataItem variable is of type "SimpleCar". The dataTable is of type HTMLDataTable. I am able to get the the first 3 SOP's but the 4th SOP isn't printed. I receive the following exception on the server :

javax.faces.el.EvaluationException: Exception while invoking expression #{selectOneRowList.editCar} org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:156) javax.faces.component.UICommand.broadcast(UICommand.java:89) javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:97) javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:171) org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:32) org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:95) org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:70) javax.faces.webapp.FacesServlet.service(FacesServlet.java:139) org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:341)

On click of the edit button the editCar method in my backing bean is invoked. I need to get the data of the selected row in my backing bean. Why is the exception occurring ?

The above example is taken from the tomawhawk examples WAR distributed on the website. I have gone through many links including the ones on BalusC but none of them have helped.

Regards,

© Stack Overflow or respective owner

Related posts about jsf