cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Lundquist ...@wrinkledog.com>
Subject [flow+forms] need help w/ binding booleanfield
Date Tue, 14 Jun 2005 19:01:13 GMT

Hi, I'm having trouble with a binding on a <booleanfield> widget.  That 
is to say, the binding seems to be working fine, but... I'm doing a 
form.save() to a Flowscript object, and when I try to access the 
property bound to the <booleanfield>, things aren't working right.  I 
think it might have something to do with some kind of Rhino/LiveScript 
object wrapping and unwrapping magic that I don't understand...

I have this in a repeater binding:

	<fb:value id="selected" path="selected">
		<fd:convertor datatype="boolean"/>
	</fb:value>


Then in the flowscript I, do this to set up the display of the form:

         var i = getCatalog().iterator();
         while (i.hasNext()) {
             var item = i.next();
             catalogChoices.push (
				 {
					catalogItem: item,
					selected: new java.lang.Boolean (false)
			 	 }
			  );
         }

         form.load (catalogChoices);


After I display the form, I call form.save() on the same catalogChoices 
object, and then I do this:

         var selections = new HashSet();
         for (i in catalogChoices) {
			var lineItem = catalogChoices[i];
             print (lineItem.selected);	// What's going on here?!?
             if (lineItem.selected) {	// always true?!
                 selections.add (lineItem.catalogItem);
             }
         }
         order.setItems (selections);

If I've checked a few of the boxes, here's what gets printed out, e.g.:

	false
	true
	true
	false
	true

...or whatever.  But... the code in the 'if' statement always runs!

So I'm trying to figure this out, and I added the following code before 
calling showForm():

	for (i in catalogChoices) {
		print (catalogChoices[i].selected.getClass();
	}

Great, it prints 'java.lang.Boolean', as expected.  But then if I add 
the same code after the call to form.save(), I get the exception 
"getClass is not a function"!

I don't get it!  Can anybody explain what's going on?

Thanks a lot,
—mark

Mime
View raw message