Search code examples
htmlstruts

struts checkbox : deselect and submit


In my JSP page I have:

<nested:checkbox property="product.hasEmployee" />

This checkbox is selected by default, when I deselect it then I submit the page, I find it selected !

how can I resolve this problem?


Solution

  • Execute this code in the server side:

    if (request.getParameter("product.hasEmployee") == null) {
         product.setHasEmployee(false);
    }