Hello Niels,
I'v found another solution for my problem. In the Class SelectionListQuestion
which extends the Question Class described in my first mail, I had to implement
two "proxy methods" that take as parameter Collection Objects:
public Collection getCollection() {
if (this.getResponse instanceof Collection) {
return (Collection)this.getResponse();
}
return new ArrayList();
}
public void setCollection(Collection col) {
this.setResponse(col);
}
In the Binding I have to point to this methods for multivalue fields and it
works. I don't no why, but it works.
Thanks,
Mike
---------- Original Message ----------------------------------
From: Niels van Kampenhout <[EMAIL PROTECTED]>
Reply-To: [email protected]
Date: Mon, 05 Dec 2005 17:17:03 +0100
>cocoon.erard wrote:
>> Hello,
>>
>> I'm trying to bind a multivaluefield with an object, but this doesn't work.
>>
>> I've a bean:
>>
>> public class MyBean {
>>
>> private HashMap questions = new HashMap();
>>
>> public HashMap getQuestions() ...
>> public void setQuestions(HashMap questions) ...
>>
>> }
>>
>> the quesitons map contains Question Objects:
>>
>> public class Question {
>> private Object response = null;
>>
>> public Object getResponse()...
>> public void setResponse(Object response)...
>>
>> }
>>
>> somewhere i make:
>>
>> myBean.getQuestions().put("name", new Question());
>> myBean.getQuestions().put("languages", new Question());
>>
>> the binding:
>>
>> <fb:context path="." xmlns:fb="http://apache.org/cocoon/forms/1.0#binding"
>> xmlns:fd="http://apache.org/cocoon/forms/1.0#definition">
>> <fb:struct id="1" path=".">
>> <fb:value id="name" path="[EMAIL PROTECTED]'name']/response"/>
>> <fb:multi-value id="languages" parent-path="[EMAIL
>> PROTECTED]'languages']/response" row-path="."/>
>> </fb:struct>
>> </fb:context>
>>
>> This works fine for the widget 'name'. If response is null, an Object of the
>> correct type is created for field widgets. If response is != null the
>> content is displayed in the form.
>> But for 'languages' (which is a selection list) I receive allways the
>> exeption at the end of the mail.
>> I've already tried out other combinations with row-path and parent-path but
>> didn't find the solution, can someone help me?
>>
>> Regars
>>
>> Mike
>
>Mike,
>
>It may be that you have to write some custom binding code in an
><fb:javascript> element. That was the only way I could get
>multivaluefield binding to work properly. For an example, check this
>thread:
>http://marc.theaimsgroup.com/?l=xml-cocoon-users&m=109653712005198&w=2.
>
>Niels
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
>
____________________________________________
QuickLine WebMail - http://www.QuickLine.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]