cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Price <simon.pr...@bristol.ac.uk>
Subject [SUMMARY] how to use a checkbox with DatabaseUpdateAction
Date Thu, 25 Jul 2002 14:55:36 GMT
Take 2... this time with correct summary prefix in email title :-)))
---

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
Simon.Price@bristol.ac.uk
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:     <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail:   <cocoon-users-help@xml.apache.org>


Mime
View raw message