File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes How to Reterive Row Data in JSF Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "How to Reterive Row Data in JSF" Watch "How to Reterive Row Data in JSF" New topic

How to Reterive Row Data in JSF

Samiullah Niazi

Joined: Aug 20, 2008
Posts: 1
Can anybody help me in reteriving particular cell of data table in JSF. I want to select ID of selected row in DataTable.

Currenty I am using as follow.

private DataModel studentDataModel=null;

As I click on the data table printing as
{address=Karachi, id=4, name=Navaid, password=nabc, username=n1234}

So my question is how to retrieve id of selected row.

I also created bean as follow.

public class Student implements Serializable {

private long id;
private String name;
private String username;
private String password;
private String address;
and I am trying to reterive row as follow

Student studentInfo=null;
studentInfo= (Student) studentDataModel.getRowData();

but on clicking on the button following error is shown :-(

500 Internal Server Error

javax.faces.FacesException: #{tableData.selectRow}: javax.faces.el.EvaluationException: java.lang.ClassCastException: javax.faces.model.ResultSetDataModel$ResultSetMap
at com.sun.faces.application.ActionListenerImpl.processAction(
at javax.faces.component.UICommand.broadcast(
at javax.faces.component.UIData.broadcast(
at javax.faces.component.UIViewRoot.broadcastEvents(
at javax.faces.component.UIViewRoot.processDecodes(
at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(
at com.sun.faces.lifecycle.LifecycleImpl.phase(
at com.sun.faces.lifecycle.LifecycleImpl.execute(
at javax.faces.webapp.FacesServlet.service(
at com.evermind[Oracle Containers for J2EE 10g ( ].server.http.ServletRequestDispatcher.invoke(
at com.evermind[Oracle Containers for J2EE 10g ( ].server.http.ServletRequestDispatcher.forwardInternal(
at com.evermind[Oracle Containers for J2EE 10g ( ].server.http.HttpRequestHandler.doProcessRequest(
at com.evermind[Oracle Containers for J2EE 10g ( ].server.http.HttpRequestHandler.processRequest(
at com.evermind[Oracle Containers for J2EE 10g ( ].server.http.HttpRequestHandler.serveOneRequest(
at com.evermind[Oracle Containers for J2EE 10g ( ]
at com.evermind[Oracle Containers for J2EE 10g ( ]
at com.evermind[Oracle Containers for J2EE 10g ( ].util.ReleasableResourcePooledExecutor$
Caused by: javax.faces.el.EvaluationException: java.lang.ClassCastException: javax.faces.model.ResultSetDataModel$ResultSetMap
at com.sun.faces.el.MethodBindingImpl.invoke(
at com.sun.faces.application.ActionListenerImpl.processAction(
... 18 more
Caused by: java.lang.ClassCastException: javax.faces.model.ResultSetDataModel$ResultSetMap
at mathmatics.TableData.selectRow(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at com.sun.faces.el.MethodBindingImpl.invoke(
... 19 more
Jerwin Louise Uy
Ranch Hand

Joined: Oct 27, 2007
Posts: 75
The table.getRowData() will return the corresponding object in the DataModel.

For example, if you set a ObjectA with a property id in the data table, table.getRowData() will give you ObjectA and not the property id.

So in your case, simply cast the object returned by the table.getRowData() to the appropriate type that contains your id.


Uy Jerwin Louise Vergara
Junior Developer / Research and Development at Incuventure Partners Corporation
I agree. Here's the link:
subject: How to Reterive Row Data in JSF
Similar Threads
possible Reasons for following Error
bothersome ServletException
getting nullPointerException on line upload.parseRequest(request);
failed to generate excel report using jasper report and JSF
NullPointerException with oc4j