Question

I want my code to do this...

<c:if test="${validated != 'Y' }">
    <form:form id="newJob" method="post" action="updateValidated" commandName="jobModel">
        <form:input path="regattaId" type="hidden" />
        <form:input path="job_id" type="hidden" />
        <table>
            <tr>
                <td><spring:message code="label.validated" />
                <td><form:radiobutton path="validated" value="Y" />Yes<form:radiobutton
                            path="validated" value="N" />No</td>
            </tr>
        </table>
        <input type="submit" class="button" value='<spring:message code="label.validateJob"/>' hidden="true" />
    </form:form>
</c:if>
<c:else>
    This job is validated
</c:else>

Any takers? Right now it doesn't work. I think my syntax is correct but I'm very new

Was it helpful?

Solution 2

the equivalent code is

    <c:choose>
    <c:when test="${validated != 'Y' }">
        <form:form id="newJob" method="post" action="updateValidated"
            commandName="jobModel">
            <form:input path="regattaId" type="hidden" />
            <form:input path="job_id" type="hidden" />
            <table>
                <tr>
                    <td><spring:message code="label.validated" />
                    <td><form:radiobutton path="validated" value="Y" />Yes<form:radiobutton
                            path="validated" value="N" />No</td>
                </tr>
            </table>
            <input type="submit" class="button"
                value='<spring:message code="label.validateJob"/>' hidden="true" />
        </form:form>
    </c:when>
    <c:otherwise>
        This job is validated
    </c:otherwise>
</c:choose>

Jstl's c:if tag doesn't have a companion c:else tag. Try c:choose!

OTHER TIPS

<c:else> doesn't exist, and has never existed. Read the documentation of what you're using instead of trying random things.

The correct way, using the JSTL, to have the equivalent of if/else is

<c:choose>
    <c:when test="condition">...</c:when>
    <c:otherwise>...</c:otherwise>
</c:choose>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top