I am trying to generate div tags dynamically depending on the number of items, contained in the 'deviceSel' from the backing beans. For each of the div tag, I am populating it by calling the 'generateSparkLine' function that is present in a JS file - 'Reports_Cap'. I need to pass the id of the iv tag for the function to populate the data in the corresponding 'div' tag.
In my current code, the divs get created with the same id and hence, the same portion gets populated onclick. Could someone help me with a way to dynamically assign ids to the div tags from the JSF file? Also, div tag is not letting me use the "onload" event and that is the reason I am using the "onclick". How could I go about modifying it so that I could get the div tags populated when the page opens up?
<div>
<ui:repeat var="deviceSel" value="#{reportViewproto.selectedDevices}">
<h:outputText value="#{deviceSel}" />
<div id="chartDiv" style="width:600px; height:400px;" onclick="Reports_Cap.generateSparkLine('chartDiv', 'generateSparkLine')"></div>
<br />
</ui:repeat>
</div>