Thanks Robin,
I came to a similar solution last night by careful deduction - what a way to find out how it works ! :-)
Robin Wyles wrote:
Jorg,
Use widget.getValue() to retrieve the selected values from a widget with a selection list.
I do something like this to bind back to the bean:
<fb:javascript id="projects" path="." direction="save"> <fb:save-form> var values = new Packages.java.util.ArrayList(); values = widget.getValue(); var user = jxpathPointer.getNode(); user.setProjects(values); </fb:save-form> </fb:javascript>
For for information look at the widget API docs: http://cocoon.apache.org/2.1/apidocs/org/apache/cocoon/forms/formmodel/ Widget.html
Hope that helps,
Robin
On 22 Sep 2004, at 17:45, Jorg Heymans wrote:
ok in situation below i have <fb:load-form> var collection = jxpathPointer.getNode(); widget.setSelectionList(collection, "id", "name"); </fb:load-form> to load up the selectionlist.
How do i now save it back to the bean? (i removed the direction attribute. Instinctively, i did
<fb:save-form>
var collection = widget.getSelectionList();
jxpathPointer.setValue(collection);
</fb:save-form>
but my instinct was wrong :-)
Any thoughts? There is so little info on this...
Jorg Heymans wrote:
setting the multivaluefield datatype to integer did the trick. I guess it is the "key" (or value - depends how you look at it) datatype that matters here, not the label.
Jorg Heymans wrote:
Hi,
I have a bean called "Profile" that populates my form. The bean has an arraylist called "targetGroups" which contains "TargetGroup" objects. (and get-set methods for this arraylist)
Each Targetgroup object has an id(Integer) and name(String).
i have a multivaluefield widget for these groups
<fd:multivaluefield id="targetgroups">
<!--is this datatype correct???? tried setting it to my TargetGroup class but it says unknown datatype -->
<fd:datatype base="string"/>
<fd:selection-list/>
</fd:multivaluefield>
I want to populate this multivaluefield with a custom binding
<fb:javascript id="targetgroups" path="targetGroups" direction="load"> <fb:load-form> var collection = jxpathPointer.getNode(); widget.setSelectionList(collection, "id", "name"); </fb:load-form> </fb:javascript>
I am getting a ClassCastException
Original Exception: java.lang.ClassCastException
at org.apache.cocoon.forms.datatype.convertor.DummyStringConvertor.conve rtToString(DummyStringConvertor.java:35)
at org.apache.cocoon.forms.datatype.typeimpl.AbstractDatatype.convertToS tring(AbstractDatatype.java:94)
at org.apache.cocoon.forms.datatype.FlowJXPathSelectionList.generateSaxF ragment(FlowJXPathSelectionList.java:119)
at org.apache.cocoon.forms.formmodel.MultiValueField.generateItemSaxFrag ment(MultiValueField.java:143)
at org.apache.cocoon.forms.formmodel.AbstractWidget.generateSaxFragment( AbstractWidget.java:369)
at org.apache.cocoon.forms.transformation.EffectWidgetReplacingPipe$Widg etHandler.process(EffectWidgetReplacingPipe.java:390)
at org.apache.cocoon.forms.transformation.EffectPipe.endElement(EffectPi pe.java:417)
at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
at org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unkn own Source
Thoughts? Jorg
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]