1
<jsp:element name="input">
    <jsp:attribute name="type">radio</jsp:attribute>
    <jsp:attribute name="id">${status.index}${loop.index}</jsp:attribute>
    <jsp:attribute name="name">skillLevel[${status.index}].skillLevelId</jsp:attribute>
    <jsp:attribute name="value">${4 - loop.index}</jsp:attribute>
    <c:if test = "${(4 - loop.index) == skillLevel.getSkillLevelId()}">
        <jsp:attribute name="checked">checked</jsp:attribute>
    </c:if>
</jsp:element>

Shows error that c:if tag cant be within jsp:element tag. I just want to add the attribute "checked" for the "input" element based on the test condition.

Xavier DSouza
  • 2,861
  • 7
  • 29
  • 40
  • Have you had a look at [this](http://stackoverflow.com/questions/3507610/jsp-can-i-use-jspattribute-inside-cif-exception-must-use-jspbody-to) question? – radimpe Jun 07 '13 at 09:04
  • @radimpe Yes..I did the same. – Xavier DSouza Jun 07 '13 at 11:02
  • Possible duplicate of [JSP - Can I use inside ? Exception: "Must use jsp:body to specify tag body"](https://stackoverflow.com/questions/3507610/jsp-can-i-use-jspattribute-inside-cif-exception-must-use-jspbody-to) – Vadzim Apr 05 '19 at 19:02

1 Answers1

0

Have you tried like this ?

<c:if test = "${(4 - loop.index) == skillLevel.getSkillLevelId()}">
<c:set var="isChecked" value="checked"/>
</c:if>

<jsp:element name="input">
    <jsp:attribute name="type">radio</jsp:attribute>
    <jsp:attribute name="id">${status.index}${loop.index}</jsp:attribute>
    <jsp:attribute name="name">skillLevel[${status.index}].skillLevelId</jsp:attribute>
    <jsp:attribute name="value">${4 - loop.index}</jsp:attribute>
    <jsp:attribute name="${isChecked}">${isChecked}</jsp:attribute>
</jsp:element>
vjy
  • 1,184
  • 1
  • 10
  • 24