| |

VerySource

 Forgot password?
 Register
Search
View: 809|Reply: 2

JSF Datatable displays ResultSetDataModel object, how to click a single record to display details

[Copy link]

2

Threads

4

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-1-17 11:20:01
| Show all posts |Read mode
I'm new to jsf, and now I have a problem. I use ResultSetDataModel to encapsulate the rs object. There is no problem displaying Dataltable on the jsf page, but I want to click on one of the records and then display the details.

The click action is bound to a select method to determine which record is selected. I only use model.getRowIndex () to get the serial number of the row that was clicked. How can I use model.getRowData () to get other information about this record?

Thank you very much!

 public String select () {

   ResultSet result2 = (ResultSet) model.getRowData (); // This sentence will be wrong
rowIndex = model.getRowIndex (); // If you just get this number, you can get
return "success";
}
Error message
javax.faces.el.EvaluationException: java.lang.ClassCastException: javax.faces.model.ResultSetDataModel $ ResultSetMap
javax.faces.webapp.FacesServlet.service (FacesServlet.java:225)

I have seen some examples, such as ListDataModel, where a single record is an object in a List, but what is a record in a ResultSet? With the ResultSet object, an error occurs.

Thank you
Reply

Use magic Report

2

Threads

4

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 Germany

 Author| Post time: 2020-1-22 22:45:01
| Show all posts
Map myMap = (Map) model.getRowData ();
msgr = (String) myMap.get ("username");

I checked the sun's documentation, model.getRowData () returned a map type, and the key value was the column name of the table. With the above method, we can get each item of the clicked item.

It is too painful to learn jsf while checking java without the basics of Java. I hope it will be helpful to other beginners! Ha ha
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-23 17:00:01
| Show all posts
JSF is really not easy to use, one step worse than asp.net usability
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list