cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris Clark" <>
Subject Checkboxes in JXForms - javascript OK, java NOT
Date Wed, 20 Aug 2003 17:55:49 GMT
Based on the samples, I've been looking at checkboxes in JXForms and have a few questions...
Given the following snippet from an xform definition:

    <xf:select ref="validchecks" appearance="full">
      <xf:label>Check if field is Present &amp; Legible</xf:label>
      <xf:itemset nodeset="fieldset">
        <xf:label ref="key"/>
        <xf:value ref="value"/>

1) Do you have to use the nodeset?  This is fine if you want multiple checks, but if I just
want one checkbox?  I tried a number of things, but none worked.  e.g. an xf:input with a
hard-coded type="checkbox".  This displayed okay, but the checked/unchecked state wasn't recorded
anywhere that I could find.  If you don't need the nodeset, is there a sample and/or docs?

2) I got the above to work in javascript with the following structure.

  var modelObj= {
      validchecks: [""], 
      // define a nodeset (list of all checkboxes in a group)
      fieldset: [{key:"Description", value:"desc"},    // key=what to display, value=what
to store in var
                 {key:"Name", value:"name"},  

When I hit submit, the validchecks is filled out with the value of anything that was checked.

3) Instead of using an object defined in javascript, I wanted to use my own Java Bean (to
facilitate access to the form data after submit).  The javascript now looks like:

  var modelObj = new Packages.elrsproto.FormBean();

The FormBean looks like this:

public class FormBean
    private String validchecks;
    private FieldBean[] fieldset = {
       new FieldBean("Description", "desc"),
       new FieldBean("Name", "name"),

FieldBean is a helper class that contains two strings named "key" and "value".

This displays correctly on screen (i.e. looks the same as the totally javascript version).
 The plain edit controls on the form and their String representations in the FormBean (not
shown) work fine.  However, only the value of the first selected checkbox shows up.  If I
check five checkboxes, I only see one value in the "validchecks" variable.  When I do this
in javascript, I see a comma-delimited list with all of the selected values.

Does this fall under the heading of "you aren't supposed to do that, so don't"?  Is this a
bug?  Do I just have the syntax wrong?  (I tried a number of things, like making the validchecks
an array, but they all threw errors of varying sorts.)



View raw message