Retaining checkbox state after validation errors

Hello,

I have a simple database login form consisting of edit fields for username, password, and database, and also a checkbox to activate a debugging feature.

For validation errors, I have been easily able to retain previously entered data in the three edit fields, in case one of the DB parameters was entered wrong and the user needs to re-enter a specific field. But I have not been able to save the checked/unchecked state of the checkbox.

Here is the code I use to retain the previously entered data of the database name edit field, for example:

<input type="text" name="databaseName" value='${param.databaseName}' size="20"/>

Works fine. But with the checkbox, I don't know how to retain the checked/unchecked state:

<input type="checkbox" name="useTestFile"

checked="?"/> Use sample XML file

What should go into the ? {$param.useTestFile .... ?} so that the state is retained between entry errors?

Thanks,

Glen

[1002 byte] By [GlenMazzaa] at [2007-10-2 9:34:41]
# 1

I found the answer to my own question, which I'm placing here in case this may help others:

<c:choose>

<c:when test="${!(empty param.useTestFile)}">

<input checked="checked" type="checkbox" name="useTestFile"/> Use sample XML file

</c:when>

<c:otherwise>

<input type="checkbox" name="useTestFile"/> Use sample XML file

</c:otherwise>

</c:choose>

GlenMazzaa at 2007-7-16 23:40:56 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...