You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Jorg Heymans <jh...@domek.be> on 2004/09/22 17:45:57 UTC
Saving the collection back to the bean using custom binding (was
Re: cforms custom binding multivaluefield)
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.convertToString(DummyStringConvertor.java:35)
>>
>> at
>> org.apache.cocoon.forms.datatype.typeimpl.AbstractDatatype.convertToString(AbstractDatatype.java:94)
>>
>> at
>> org.apache.cocoon.forms.datatype.FlowJXPathSelectionList.generateSaxFragment(FlowJXPathSelectionList.java:119)
>>
>> at
>> org.apache.cocoon.forms.formmodel.MultiValueField.generateItemSaxFragment(MultiValueField.java:143)
>>
>> at
>> org.apache.cocoon.forms.formmodel.AbstractWidget.generateSaxFragment(AbstractWidget.java:369)
>>
>> at
>> org.apache.cocoon.forms.transformation.EffectWidgetReplacingPipe$WidgetHandler.process(EffectWidgetReplacingPipe.java:390)
>>
>> at
>> org.apache.cocoon.forms.transformation.EffectPipe.endElement(EffectPipe.java:417)
>>
>> at
>> org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
>> at
>> org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown
>> Source
>>
>>
>> Thoughts?
>> Jorg
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Saving the collection back to the bean using custom binding (was
Re: cforms custom binding multivaluefield)
Posted by Jorg Heymans <jh...@domek.be>.
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: users-unsubscribe@cocoon.apache.org
>> For additional commands, e-mail: users-help@cocoon.apache.org
>>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Saving the collection back to the bean using custom binding (was Re: cforms custom binding multivaluefield)
Posted by Robin Wyles <ro...@robinwyles.com>.
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: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org