I've come up with a code-free workaround for the problem.

Quick reminder of the problem: HTML checkboxes do not submit a request 
value if unchecked and hence DatabaseUpdateAction writes NULL into the 
corresponding column in the database. In Cocoon 2.03 there in no way of 
overriding this effective "NULL default".

What is more typically required is something like: when checked, write 
"Y"; when unchecked, write "N". By adding a hidden input field of the 
same name as the checkbox input field to your HTML form you can force a 
non-NULL default.

eg. my version of simple-page.xsl generates HTML for a checkbox as...

         <input type="checkbox" name="{@name}" value="Y">
           <xsl:if test=".='Y'">
             <xsl:attribute name="checked">true</xsl:attribute>
           </xsl:if>
         </input>
         <!-- default value for when checkbox is left unchecked -->
         <input type="hidden" name="{@name}" value="N"/>

When the box is checked, the Y is written, but when unchecked, the N is 
written.

Cheers

Simon

PS. Tested with Cocoon 2.03, Java 1.3.1, Tomcat 4.01, IE6 and NS6

-------------------------------------------------------------------
Simon Price
Institute for Learning and Research Technology
University of Bristol
8-10 Berkeley Square
Bristol BS8 1HH
United Kingdom

Direct: +44 (0)7071 226 720
Office: +44 (0)117 928 7193
Fax: +44 (0)117 928 7112
[EMAIL PROTECTED]
http://www.ilrt.bristol.ac.uk


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <[EMAIL PROTECTED]>
For additional commands, e-mail:   <[EMAIL PROTECTED]>

Reply via email to