I want to access model items by index from JavaScript into a Play Framework template:
<script type="text/javascript" charset="utf-8">
window.onload = function()
{
var cl = ${colors.size()};
int i = 0;
for (i=0;i<cl;i++)
{
labels = labels + "${colors.name.get(i).escapeJavaScript().raw()}";
}
}
</script>
My problem is that this loop throws an exception:
IndexOutOfBoundsException : Index: 12, Size: 4
Nota 0: model = Color.
Nota 1: the size is 4.
Nota 2: if I test with a fixed number instead of variable i it is ok, but this is not what I need.
Cannot get why it does not work.
varandint, and assuming that the JavaScriptiis available in Java.