I'm trying to nest a ui:repeat or another DataTable inside of my original DataTable so I can display another list.
So the original DataTable uses one list and the nested ui:repeat is using another but the ui:repeat isn't iterating through it, instead it's just displaying the entire list for each DataTable row.
Here's the nested ui:repeat I have currently
<h:column>
<ui:repeat value="#{readingBean.list}" var="amount">
#{amount}
</ui:repeat>
<f:facet name="header">Amount Used</f:facet>
</h:column>
This is where I get the data for populating the original DataTable
public List<Reading> getReadingData() {
List<Reading> readingByMeter = (em.createNamedQuery("Reading.findByMeter").setParameter("meter",name)).getResultList();
return readingByMeter;
}
Here's the second list I want nested in
public List<Double> getList() {
List<Reading> readingData = (em.createNamedQuery("Reading.findByMeter").setParameter("meter",name)).getResultList();
List<Double> list = new ArrayList<Double>();
for (int i = 1; i < readingData.size(); i++)
{
list.add((readingData.get(i).getReading().doubleValue() - readingData.get(i - 1).getReading().doubleValue()) / 50);
}
return list;
}
So for the second list I'm calculating an amount by subtracting the 2nd element in the original list by the first element and then dividing by 50. So it would be (1 - (1 -1)) / 50 and then (2 - (2 - 1)) / 50 and so on. Taking the next element and subtracting it by the previous.
This is what it looks like with the ui:repeat inside of the DataTable currently
DataTable Display Current - But I want it to be listed as
2050 | 43.0
4200 | 38.0
and so on
So my question is how to display my second list in the original datatable's columns so that it appears as above. I searched a lot and couldn't find any solution so any help is appreciated. Also please let me know if you need any more information