Hello, I'm hoping you guys can help, because I'm stuck. I'm trying to create a dynamic JSF datatable that has dynamic rows and columns and I'm using BalusC code as an example http://balusc.blogspot.com/2006/06/using-datatables.html#PopulateDynamicDatatable I've entered his code and it works, but I'm confused on how it works because for his FOR statement he has it as I don't understand how it can iterate through the list when he has it .get(0). But on to my real problem, his code works for me for just creating a datatable and displaying the information, but what I need to do is loop through all the fields and see if they are null and if they are change the background color of the cell. With the way he has his code, I can't figure out how to iterate through the fields so I can see what each one's value is. I hope this makes sense and if you need me to re-word anything just let me know. Any help would be great thanks.
The get(0) part is easy to explain. He is using a matrix structure. He has a list of lists. The get(0) just returns the first list or the first "row" and he is iterating through it. So he is not going through the entire table but only the first row.
If you want to go through the entire table (every cell of the table) you can do it for example with two for loops. I leave it to you to learn how
The "usual" way of creating a html table this way would be to create the cells inside the inner for loop. But you do not do that here. If you want to see what your code does go each iteration (on both loops) over with a piece of paper and pen and see what is created as a result.
In any case if I understand correctly how BalusC:s code works you can not do what you intend to do here. The table is created automatically (by JSF) and BalusC:s code only tells JSF how many columns the table has and the names of the headers. But you try to create the entire table.
Well this is what I’m trying to do ultimately, I know it’s not the best picture, but hopefully this will help. My table with have dynamic columns and rows and in each cell they will have inputText boxes with values. The user can change the values and update them if they want. What I need to be able to do is iterate through the table and check out all the values so that if one is null I can change the background color of the cell and display an error message. The only example I have found that comes close to what I'm trying to do is BalusC code, but it sounds like his code won’t work for me. Does anyone have any suggestions or links that would help me out? Thanks.