cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeremy Quinn <jer...@apache.org>
Subject Re: CForms : multivaluefield
Date Thu, 26 May 2005 14:19:17 GMT
Hi Guys

I really think I have a bug ..... but before I escalate this, could  
someone give me a sanity check ?

I have a bunch of Strings in an ArrayList in provider.resourceList :

function addInstrument(form) {
     . . .
     var unit = {
         resources:provider.resourceList,
         . . .
     };
     form.load(unit);
     form.showForm(screen, {resources:getSimpleSelectionList 
(provider.resourceList)});
     form.save(unit);
     . . .
}

// make a Selection List from a List of Strings
function getSimpleSelectionList(list) {
     var out = new Array(list.size());
     for (var i = 0; i < list.size(); i++) out[i] = {value: list.get 
(i)};
     return out;
}

Model:

     <fd:multivaluefield id="resources">
       <fd:label><i18n:text  
i18n:catalogue="editor">instrument.resources.label</i18n:text></ 
fd:label>
       <fd:datatype base="string"/>
       <fd:validation><fd:value-count min="1"/></fd:validation>
       <fd:selection-list type="flow-jxpath" list-path="resources"  
value-path="value" label-path="value"/>
     </fd:multivaluefield>

Binding :

     <fb:multi-value id="resources" parent-path="." row- 
path="resources" direction="both"/>

Template :

     <ft:widget id="resources"><fi:styling list-type="checkbox"/></ 
ft:widget>

So, you start off with a form with a list of Checkboxes, all selected.
eg.
         X Item One
         X Item Two
         X Item Three

You uncheck Items Two and Three, your resulting list contains Item  
One, Item Two.
Instead if you uncheck One and Two, your resulting list contains Item  
Three, Item Two.
Instead you uncheck One and Three, your resulting list contains Item  
Two, Item Two.

Is this as broken as it seems? Or have I done something stupid with  
my binding (etc.) ?


Thanks for any suggestions.


regards Jeremy



On 25 May 2005, at 18:50, Jeremy Quinn wrote:

> Hi All,
>
> I am using a multivaluefield and I am having strange effects.
>
> I have a form to edit a Bean. The Bean has an ArrayList which is  
> populated with a bunch of Strings. The form displays this ArrayList  
> in a multivaluefield, which has all entries initially selected by  
> having identical items in both the selectionlist and the Bean. You  
> use the Form to deselect some of the entries.
>
> I found that I was getting deselected (and sometimes duplicated)  
> entries in the Bean after the form had been used.
>
>
> What appears to be happening, is that when  
> o.a.c.forms.bindingMultiValueJXPathBinding calls  
> multiValueContext.removeAll(this.rowPath), not all entries are  
> removed.
>
> I started with a Bean that had 4 items in it's ArrayList.
>
> I counted the items in the ArrayList either side of the call to  
> removeAll :
>
>     multiValueContext.getValue("count(" + this.rowPath + ")");
>
> The first time it is called it reports 4, after removeAll it  
> reports 3.
>
> In fact removeAll in this case only ever seems to remove one entry.  
> So the reason that this does not show up in the "form2_bind_bean"  
> CForms Sample, appears to be that it has only 2 items in the Bean  
> to start with and has validation to only allow 2 to be submitted.
>
> Looking at  
> org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.removeAll I  
> do not see any obvious reasons why it is not working.
>
>
> Any suggestions anyone ?
>
> Can anyone else replicate this problem ?
>
> Or am I barking up the wrong tree ?
>
>
> regards Jeremy
>
>
>


Mime
View raw message