I have a Data Table that's currently mapped to a ResultSet.
It displays data, but I'm not able to interact with it so I changed it to a MyFaces Data Table to see if that would allow me to click a check box and have that data saved in the updateable ResultSet (so I can determine which rows the user clicked).
To change the Core Data Table to a My Faces data table, I added the required line:
Well, there are a few MyFaces specific entries that go in the web.xml. Download the examples zip and run the simple.war and then look at it's web.xml to see what you need.
As far as all your ResultSet issues, to be honest, I haven't dealt with straight JDBC for a very long time. It gets very tedious once you start using something like iBatis or Hibernate along with Spring.
Here is what I would suggest you do. Get away from binding to ResultSet's. Move all the data out of the ResultSet and into some sort of Pojo/Bean/whatever. Put those objects in a List and bind your data table to that list of objects. Then, when one of those objects' data changes, submit that update to the database in your data access layer. You don't have to change any of your JDBC stuff. Just add another layer, a model layer that isn't JDBC (ResultSets).
Tonight, when I get home from work, and if you ask nicely, , I'll whip out a quick example of what I am talking about and send you the entire project so you can see what I am talking about. If you need it that is. Let me know.
Originally posted by Gregg Bolinger: Mike, where do you want me to send the code?
Could you post it here (or if it's too big, provide a URL)? JavaRanch is for sharing!
An IDE is no substitute for an Intelligent Developer.
Joined: Jul 12, 2002
I'll be glad to post Gregg's code in a day or two once I complete this project or Gregg can do in the meantime. <s>
What I did to fix the problems I was having was to, as Gregg suggested, dump the ArrayList as the Data List's data source and instead just use the ResultSet to create an ArrayList (I changed the DataModel to ListDataModel and little things like that).
Now, all is working great!
My project is almost done.
Thanks for all the fantastic help!!!
Joined: Jul 12, 2002
In my reply above I meant to say ...dump the *ResultSet* for the data source for the data table and just use the ResultSet to populate an ArrayList for the Data Table.
If you take the example I provided "list" would == "personList" and it's up to you to provide a sort()/ascending() method to sort your data in the list. It doesn't have to be called sort/ascending. You could call it sortThisCrap(). It works the same as calling an actionListener or action method.
You *might* have to give those methods a string and boolean argument though for MyFaces sorting. I am not 100% sure about that. I haven't really messed much with sorting. I downloaded the example simple.war source code and have been looking at that. [ December 28, 2005: Message edited by: Gregg Bolinger ]