I have a ArrayList of ArrayList - I declare it in this way:
ArrayList<ArrayList<String>> queryResult=new ArrayList<ArrayList<String>>();
Then I add a new element to array like this:
for(int i=1;i<colNumber;i++)
{
queryResult.add(new ArrayList<String>(20));
}
after that I add a value to elements of array:
while(r.next())
{
for(int i=0;i<colNumber;i++)
{
queryResult.get(i).add(r.getString(i));
}
}
But when I try to use it in DataTable tag I see nothing :(
<h:dataTable value="#{polaczenieSQL.queryResult}" var="w">
<h:column>
<f:facet name="head">typ</f:facet>
#{w[0]}
</h:column>
What I am doing wrong? How should I use this array in JSF?
Ps this is my faces.config:
<managed-property>
<property-name>queryResult</property-name>
<property-class>java.util.ArrayList</property-class>
<list-entries></list-entries>
</managed-property>
I found first problem:
r.getString(i)
I added a
System.out.print("something")
after a loop but it doesn't want to print.
When I change a variable 'i' and type for example: 4 I see "something" on my console . Variable 'colNumber' is set to 5 (but my sql table have 7 columns and I use "select * from mytable" so I dont think that is a counter problem ).
faces-config?ResultSet#getString()would throwSQLException: invalid indexwhen0is passed. The problem is at least not visibe in the code posted so far (at least, not the technical problem which you're talking about; there are however severe design problems). I'm also not sure why this question got 2 upvotes as it's unanswerable in its current form and exposes poor practices.