cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Re: [Announcement] XMLForm 0.81 available in Scratchpad
Date Mon, 06 May 2002 23:09:49 GMT


      I'm new to java, so there are probably better ways to do this.
      I'm not using CVS (yet!) so I can't supply a simple diff file.

1) Added accessor methods for a Collection (ArrayList) variable to the data
model.  Is there a better choice?
2) Filled in the stubs for handling <xf:selectMany> already in  This created the <xf:selectMany> tag, but it had only
one <xf:value> child.
3) Changed StartTransformingElement function to detect an instance of Collection
in the value_ returned from form.getValue() and iterated through the Collection
to create the necessary multiple <xf:value> tags.
4) Added a template to xmlform2html .xsl to process the xf:selectMany tag and
generate either a checkbox set or multiple-select list (based on <xf:selectMany
@hint="checkbox">).  Now I had the output I was looking for, but when I tried to
submit the form I kept getting errors from jxpath.
5) Changed the convert function in to recognize String arrays coming
from the request (it seems to convert only String scalars) and to convert them
to ArrayList type.
6) Extended WizardAction (for other reasons), and modified the reset function to
set data model to empty ArrayList before population.

There are (at least) several fishy things here: 1) Don't know what happens when
DOM nodes are used for multiple-select.  (Don't really understand the
purpose/use of DOM nodes in data model for that matter)  2) Types stuff is just
a working hack.  No provision for converting anything but an ArrayList, and not
sure if I'm even doing this the right way.  3) I very much prefer your idea of
using "selectUIType" attribute instead of "hint" attribute.  I'll work on these
things when I get time.

Also, I'm struggling a bit with the best way to handle "presentation" of
multiple-select lists rendered as checkbox set.  All other form widgets, item
captions render only one way (e.g. options in select list).  But with checkbox
sets, item captions may be rendered to right of checkbox, to left of checkbox,
above checkbox, below checkbox, etc.  For now, my template just places them to
right of checkbox, but this needs to be more flexible.


1) In
Filled in stub for selectMany tag in  StartTransformingElement():
      else if (TAG_SELECTMANY.equals(name))
            //NYI - Not Yet Implemented
                  //throw new SAXException("tag selectMany Not Yet
             startElementSimpleField( uri, name, raw, attributes, currentForm );

and EndTransformingElement():
      else if (TAG_SELECTMANY.equals(name))
                  super.endElement(uri, name, raw);

and inserted code for handling Collections:

      // render the value subelement(s)
      if (value_ instanceof Collection)
            Iterator i=((Collection) value_).iterator();
            while (i.hasNext())
                  super.startElement(uri, "value", NS_PREFIX + ":" + "value",
                    if (value_ != null)
                        String v = String.valueOf( );
                    super.endElement( uri, "value", NS_PREFIX + ":" + "value" );
              super.startElement(uri, "value", NS_PREFIX + ":" + "value",
              if (value_ != null)
                  String v = String.valueOf( value_ );
              super.endElement( uri, "value", NS_PREFIX + ":" + "value" );

2) In the convert function has a block of code for converting request
parameter Strings to various Object types, but no similar block for request
parameter String[].  Maybe they are supposed to "drop through" and be processed
below, don't entirely understand this.  Anyway this caused all sorts of jxpath
errors when I tried to use form.setValue(path, values), so I used "brute force"
and hacked in the following:
            else if (object instanceof String[]){
                  /* WARNING: THIS IS A REAL HACK!
                   * Inserted to handle conversion of string array from request
into ArrayList.
                   * Should write "converters" from String[] to other types of
Java objects
                   * Not sure this belongs here at all, should look at
                   * stuff below, but this works for now...
                  if (toType == ArrayList.class){
                        String[] tempString = (String[]) object;
                        ArrayList newArrayList = new ArrayList();
                        for (int n=0;n<tempString.length;n++){
                        return newArrayList;


                      "Ivelin Ivanov"                                                    
                      <ivelin@apache.or        To:       <>
                      g>                       cc:                                    
                                               Subject:  Re: [Announcement] XMLForm 0.81 available
                      05/06/02 06:33 AM         Scratchpad                               
                      Please respond to                                                  

Sure feel free to patch.

Actually, thanks for patching ;)

I'd be curious to see the diff.

Can you descripe in short what behaviour you added to implement selectMany ?


----- Original Message -----
From: <>
To: <>
Sent: Saturday, May 04, 2002 11:43 PM
Subject: Re: [Announcement] XMLForm 0.81 available in Scratchpad

> Ivelin,
> I found the places in that needed filling in and
> a patch into  I now have xf:selectMany working well enough for
> testing purposes.  Let me know if you have any general advice about
> these files...
> Thanks,
> --Michael
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, email:

To unsubscribe, e-mail:
For additional commands, email:

To unsubscribe, e-mail:
For additional commands, email:

View raw message