I have the following JSP code for a table
<table>
<c:if test="${testruns.employeecase != null}">
<tr><th colspan="2" class="labelOnLeft">
<label class="labelOnLeft">
<html:checkbox name="testruns" indexed="true" property="selectedCheckbox" />
<bean:write name="testruns" property="label" /> - <bean:write name="testruns" property="employeecase" />
<c:if test ="${testruns.testAvailable}">Test Available </c:if></label>
<html:hidden name="testruns"indexed="true" property="label" /></th></tr>
and I’m mainly concerned about setting the text color for the line <c: if test ="${testruns.testAvailable}">Test Available </c:if>. So if the condition is true, the text Test Available is printed on the screen and I want to do css work here, maybe inline and set the color of the text to red. How should I go about it?
I don’t want to do it on labelOnLeft class as that will apply the color to everything inside the label tag. Should I not use <c:if> tag and use something else?
>Solution :
You can use the style attribute to set the color of the text inline. You can modify the <c:if> tag to include the style attribute and set its value based on the condition.
Here’s an example:
<c:if test="${testruns.testAvailable}">
<span style="color: red;">Test Available</span>
</c:if>
In this example, if the testAvailable property of testruns is true, the text "Test Available" will be displayed in red color using the tag and the style attribute. You can adjust the color value to any color of your choice.