In my JSP page, I am getting double values as obtained from database. Inside a scriptlet tag, I am initializing java variables to be used as shown below :
<body>
<%
Map<String, Double> colorMap = new HashMap<>();
colorMap = InsightDbConn.getInstance().getFpyRtyColorLimits();
double var_yellow = colorMap.get("fpy_yellow"); // storing 85
double var_green = colorMap.get("fpy_green"); // storing 93
%>
I need to use these values so as to set the row colors of the table based on the values I have obtained. I am using a CSS class to set the row colors. But to define that class value, I am using JSP's ternary operator to loop through the values obtained from database.
Below is my code :
<c:forEach items="${fpyrtyDailyList}" var="entry">
<tr>
<td>${entry.category}</td>
<td>
<div class="${entry.percentage == 0 ? 'green' : entry.percentage < var_yellow ? 'red' : entry.percentage < var_green ? 'yellow' : 'green' }">
${entry.percentage}
</div>
</td>
<td>${entry.daily_date}</td>
<td>${entry.total_tests}</td>
<td>${entry.total_passed}</td>
</tr>
</c:forEach>
As seen in the above code, I am trying to set the value of CSS class with the help of Java variables i defined in scriptlet. If i use numerical values, the work gets done. The values are dynamic and may change over time so I intend to use the scriptlet variables instead.
Can someone kindly tell where I went wrong.
EDIT 1 : I wish to iterate the CSS class value inside the loop so that every row gets its own row color based on value it holds