hi there,
i have a form with a repeater containing a multivaluefield.
i noticed following issues:
- when i submit the form, the selected items (the ones in the
right select-multiple-box) are not selected
- when i select them manually before submitting only the last
value is saved
below is my sample
regards, alex
btw: i'm using cocoon 2.1.10
here's the snipped of the repeater in the definition
<fd:repeater id="selection">
<fd:widgets>
<fd:field id="selectedClient">
<fd:datatype base="string"/>
<fd:label><i18n:text>
ta_createRebookings.job_selectedClient</i18n:text></fd:label>
<fd:selection-list/>
<fd:on-value-changed>
<javascript>
var widget=event.source;
var
gWidget=widget.lookupWidget('../selectedGroups');
if(widget.getValue()!=null){
gWidget.setState(ACTIVE);
var
client=PoOrganisationService.getClient(widget.getValue());
var
orgHierarchy=PoOrganisationService.getOrgHierarchy(client);
var
topLevelGroup=orgHierarchy.getTopLevelGroup();
var
clientsGroups=PoOrganisationService.findAllChildGroupsFlat(orgHierarchy.getTopLevelGroup());
gWidget.setSelectionList(clientsGroups,"UID","shortName");
} else {
gWidget.setState(INVISIBLE);
}
</javascript>
</fd:on-value-changed>
</fd:field>
<fd:multivaluefield id="selectedGroups" state=
"invisible">
<fd:datatype base="string"/>
<fd:label><i18n:text>
ta_createRebookings.job_selectedGroups</i18n:text></fd:label>
<fd:selection-list/>
</fd:multivaluefield>
<fd:row-action id="deleteSelection" command=
"delete">
<fd:label><i18n:text>po_delete
</i18n:text></fd:label>
</fd:row-action>
</fd:widgets>
</fd:repeater>
<fd:repeater-action id="addSelection" command="add-row" repeater=
"selection">
<fd:label><i18n:text>po_add</i18n:text></fd:label>
<fd:on-action>
<javascript>
var widget=event.source;
var
repeater=widget.lookupWidget('../selection');
if(repeater.getSize()>0){
var
lastRow=repeater.getRow(repeater.getSize()-1);
var
cWidget=lastRow.lookupWidget('selectedClient');
var
allClients=PoOrganisationService.loadAllClients();
allClients.add(0,null);
cWidget.setSelectionList(allClients,'UID','name');
}
</javascript>
</fd:on-action>
</fd:repeater-action>
here's the template-snippet:
<table>
<tr>
<th><ft:repeater-widget-label id="selection"
widget-id="selectedClient"/></th>
<th><ft:repeater-widget-label id="selection"
widget-id="selectedGroups"/></th>
<th/>
</tr>
<ft:repeater-widget id="selection">
<tr>
<td>
<ft:widget id="selectedClient">
<fi:styling
submit-on-change="true"/>
</ft:widget>
</td>
<td>
<ft:widget id="selectedGroups">
<fi:styling list-type=
"double-listbox">
<fi:available-label><i18n:text>
ta_createRebookings.job_selectedGroups_Available
</i18n:text></fi:available-label>
<fi:selected-label><i18n:text>
ta_createRebookings.job_selectedGroups_Selected
</i18n:text></fi:selected-label>
</fi:styling>
</ft:widget>
</td>
<td><ft:widget id="deleteSelection"/></td>
</tr>
</ft:repeater-widget>
</table>
<ft:widget id="addSelection"/>
and here's the binding-snippet:
<fb:repeater id="selection" parent-path="selections" row-path=
"selection">
<fb:javascript id="selectedClient" path="client/@uid">
<fb:load-form>
var
allClients=PoOrganisationService.loadAllClients();
allClients.add(0,null);
java.lang.System.out.println("allClients:
" + allClients);
widget.setSelectionList(allClients,"UID","name");
widget.setValue(jxpathPointer.getValue());
</fb:load-form>
<fb:save-form>
jxpathPointer.setValue(widget.getValue());
</fb:save-form>
</fb:javascript>
<fb:multi-value id="selectedGroups" parent-path=
"selectedGroups" row-path="group/@uid"/>
</fb:repeater>