cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bruno Dumon <br...@outerthought.org>
Subject Re: cvs commit: cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/datatype/convertor PlainBooleanConvertor.java
Date Fri, 05 Dec 2003 11:05:38 GMT
sorry for the late follow-up, I've been out-of-office the last two days.

On Tue, 2003-12-02 at 23:04, Vadim Gritsenko wrote:
> Bruno Dumon wrote:
> 
> >On Tue, 2003-12-02 at 18:02, Vadim Gritsenko wrote:
> >  
> >
> >>Bruno Dumon wrote:
> >>
> ..
> 
> >>>My intuition tells me that a BooleanConvertor should return a Boolean
> >>>object.
> >>>
> >>>What's the purpose of this, IOW what is affected by this? 
> >>>
> >>>      
> >>>
> >>Commit log says it all: instead of null, JavaBean gets Boolean.FALSE, 
> >>which is, as I believe, wrong: you should not bind FALSE instead of null.
> >>    
> >>
> >
> >Still trying to understand how you're using it in order to fully
> >understand the problem:
> >Where exactly are you using the convertor? In the binding definition? If
> >the Javabean holds a Boolean property, why do you need the convertor
> >there?
> >  
> >
> 
> Ok, step by step. Here is model:
>     <wd:field id="hasSomething">
>       <wd:datatype base="boolean">
>         <wd:convertor type="plain"/>
>       </wd:datatype>
>       <wd:selection-list>
>         <wd:item value="true">
>           <wd:label>Yes</wd:label>
>         </wd:item>
>         <wd:item value="false">
>           <wd:label>No</wd:label>
>         </wd:item>
>         <wd:item value="">
>           <wd:label>Dunno</wd:label>
>         </wd:item>
>       </wd:selection-list>
>     </wd:field>
> 
> Template:
>   <wt:widget id="hasSomething">
>     <wi:styling list-type="radio" list-orientation="horizontal"/>
>   </wt:widget>
> 
> Binding:
>     <wb:value id="hasSomething" path="something"/>
> 
> Bean:
>     void setSomething(Boolean);
>     Boolean getSomething();
> 
> 
> It did not work before the patch; convertor was returning Boolean.FALSE 
> when, in fact, the value was NULL.

Aha, I finally got it. The problem is that the selection list doesn't
allow an empty (or null) value. If you look into the generated HTML
source you'll see that the "Dunno" choice also has a value of "false". I
think this is something that should be fixed in the selection lists,
i.e. if the wd:item/@value attribute is empty, don't call the convertor
but put a null value in the selection list. (and vice-versa, if the
value in the selection list is null, don't call the convertor but output
an empty string)

-- 
Bruno Dumon                             http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
bruno@outerthought.org                          bruno@apache.org


Mime
View raw message